Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Como criar um MP3 player no Maemo

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

Acredita-se que este artigo ainda seja válido no contexto original (quando ele foi escrito)

Article Metadata

Artigo
Tradução:
Por maiconherverton
Última alteração feita por hamishwillee em 14 Jun 2013

Este código-fonte mostra como criar um MP3 player simples na plataforma Maemo.

#!/usr/bin/python
import pygst
pygst.require("0.10")
import gst
import pygtk
import gtk
import hildon
 
class Player(hildon.Program):
def __init__(self):
hildon.Program.__init__(self)
self.window = hildon.Window()
self.window.connect("delete_event", gtk.main_quit)
self.window.set_title("Player")
self.add_window(self.window)
 
self.create_interface()
self.create_pipeline()
 
self.window.add(self.table)
self.window.show_all()
 
def create_interface(self):
self.table = gtk.Table(2,2,True)
buttonPlay = gtk.Button("Tocar")
buttonPause = gtk.Button("Pausar")
buttonStop = gtk.Button("Parar")
buttonOpen = gtk.Button("Abrir")
 
buttonPlay.connect("clicked",self.OnPlay)
buttonPause.connect("clicked",self.OnPause)
buttonStop.connect("clicked",self.OnStop)
buttonOpen.connect("clicked",self.OnOpen)
 
self.table.attach(buttonPlay,0,1,0,1)
self.table.attach(buttonPause,1,2,0,1)
self.table.attach(buttonStop,0,1,1,2)
self.table.attach(buttonOpen,1,2,1,2)
 
def create_pipeline(self):
# Criar bits GStreamer e bobs
 
self.pipeline = gst.Pipeline("mypipeline")
 
self.audiosrc = gst.element_factory_make("gnomevfssrc","source")
self.pipeline.add(self.audiosrc)
 
self.audiosink = gst.element_factory_make("dspmp3sink", "sink")
self.pipeline.add(self.audiosink)
 
self.audiosrc.link(self.audiosink)
 
def OnPlay(self, widget):
self.pipeline.set_state(gst.STATE_PLAYING)
 
def OnPause(self, widget):
self.pipeline.set_state(gst.STATE_PAUSED)
 
def OnStop(self, widget):
if self.pipeline.get_state() != gst.STATE_PAUSED:
self.pipeline.set_state(gst.STATE_PAUSED)
if self.pipeline.get_state() != gst.STATE_NULL:
self.pipeline.set_state(gst.STATE_NULL)
 
def OnOpen(self, widget):
dialog = hildon.FileChooserDialog(self.window,gtk.FILE_CHOOSER_ACTION_OPEN)
response = dialog.run()
dialog.hide()
file_name = selector.get_filename()
if response == gtk.RESPONSE_OK:
self.audiosrc.set_property("location", file_name)
self.pipeline.set_state(gst.STATE_READY)
 
start=Player()
gtk.main()
This page was last modified on 14 June 2013, at 05:35.
307 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×