View Single Post
Posts: 805 | Thanked: 1,605 times | Joined on Feb 2010 @ Gdynia, Poland
#3
Ok, I couldn't sleep today and lack of skills in python programming didn't stop me from writing that :P It's really in very beta-stage (as I said in previous sentence, this is my first code written in Python), so it could not install (app manager shows 2.3 mb of space needed - wtf? Both files have less, than 2 kb :P) or kill all you widgets from desktop... But for me it worked And after reboot or removing widget from desktop and adding once again - you need to click on settings and show it music file it should play. I can assure you it plays wav files, haven't tried different, it's 4:20 AM in here... It plays basically everything, which command "play-sound" can play (it uses it). These are basically just two files:
/usr/lib/hildon-desktop/mmmaudiowidget.py
/usr/share/applications/hildon-home/mmmaudiowidget.desktop

Source of the first one (the important one) is as follows:
Code:
import gtk
import hildondesktop
import hildon
import os

class MmmAudioWidgetPlugin(hildondesktop.HomePluginItem):
    def __init__(self):
        hildondesktop.HomePluginItem.__init__(self)
        self.set_size_request(90, 90)
        button = gtk.Button("Play")
        button.connect("clicked", self.play_clicked)
        button.show_all()
        self.add(button)
	self.set_settings(True)
	self.connect("show-settings", self.show_dialog)
        self.sound_file = "/home/user/MyDocs/sound.wav"
    def show_dialog(self, plugin):
        chooser = hildon.FileChooserDialog(plugin, gtk.FILE_CHOOSER_ACTION_OPEN)
        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            self.sound_file = chooser.get_filename()
        chooser.destroy()
    def play_clicked(self, button):
        os.system("echo \"" + self.sound_file + "\"")
        os.system("play-sound \"" + self.sound_file + "\"");

hd_plugin_type = MmmAudioWidgetPlugin

# The code below is just for testing purposes.
# It allows to run the widget as a standalone process.
if __name__ == "__main__":
    import gobject
    gobject.type_register(hd_plugin_type)
    obj = gobject.new(hd_plugin_type, plugin_id="plugin_id")
    obj.show_all()
    gtk.main()
Just download deb and open via appmanager. If it fails to install, try install recaller (I copied required dependencies from it) and try again. Tell me if it works for you It is called in widget menu "mmmAudioWidget" and after selecting should put ugly gray "Play" button on your active homescreen.

Last edited by misiak; 2011-04-23 at 12:15. Reason: Link removed, see post below