Pal Szasz wrote: > Hi! > > I'm writing a small plugin to play karaoke files (cdg) using pykaraoke > (pycdg) from inside freevo. > So far I got this (please note that I'm not a python developer): > > --------8<-------- > import config, plugin, os, re > from event import * > > class PluginInterface(plugin.ItemPlugin): > """ > This plugin should add an option to play the CDG karaoke file if present. > > Activate with: > | plugin.activate('audio.karaoke') > > """ > > def __init__(self): > plugin.ItemPlugin.__init__(self) > > def actions(self, item): > > if item.type == 'audio': > > self.file = None > self.item = item > self.cdgname = "" > self.files = item.files.get() > > if (len(self.files) != 1): > return [] > > self.file = self.files[0] > > # now check if there is a matching CDG file > self.cdgname = re.sub('.mp3', '.cdg', self.file) > > if os.path.exists(self.cdgname): > return [ ( self.play_cdg , _('Karaoke')) ] > > return [] > > def play_cdg(self, arg=None, menuw=None): > cmd = "pycdg -f \"" + self.cdgname + "\"" > os.system(cmd) > --------8<-------- > > So far so good: in the submenu of mp3 files there will be a new item, > "karaoke", if a cdg file exists with the same basename. When the user > selects this menu item, the plugin will simply launch pycdg. However > it would be really usefull to control pycdg. Since I haven't saw any > slave-mode support, I was thinking of implementing just the EXIT and > STOP events, by simply killing the pycdg process... however I have no > idea how to do that :-(. Any suggestions?
The best way is to look at some code that does something similar to what you want. For an audio player, mplayer is a good bet (src/audio/plugins/mplayer.py). What happens is that there is a control class derived from ChildApp. The stop event will send a quit command to the application if the application doesn't have a slave mode then childapp will kill the application. Since pykaraoke is a python application you could ask the author for some remote control features. HTH Duncan ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel