44 lines
994 B
Python
44 lines
994 B
Python
|
#!/usr/bin/python
|
||
|
|
||
|
from mediaserver.audioplayer import AudioPlayer
|
||
|
from mediaserver.quickplayer import QuickPlayer
|
||
|
from gi.repository import GObject
|
||
|
|
||
|
|
||
|
def onReady(player, file, tags):
|
||
|
print "Starting {0} ...\n".format(file)
|
||
|
print " Tags:\n"
|
||
|
for tag in tags:
|
||
|
print " {0} : '{1}'\n".format(tag,tags[tag])
|
||
|
|
||
|
duration = player.duration()
|
||
|
pos = player.position()
|
||
|
print "Song duration is {0} seconds".format(duration)
|
||
|
print "Current position is {0} seconds".format(pos)
|
||
|
|
||
|
player.playfor(20)
|
||
|
|
||
|
def onPlaying(player):
|
||
|
|
||
|
print "Playing ..."
|
||
|
|
||
|
#print "Jumping to 40 seconds"
|
||
|
#player.seek(40)
|
||
|
|
||
|
def onStop(player):
|
||
|
print "Quitting...."
|
||
|
loop.quit()
|
||
|
|
||
|
player = AudioPlayer()
|
||
|
player.connect("playback-ready",onReady)
|
||
|
player.connect("playback-playing",onPlaying)
|
||
|
player.connect("playback-finished",onStop)
|
||
|
player.connect("playback-stopped",onStop)
|
||
|
|
||
|
player.load("/opt/mediacore/mediaserver2/snnw_E_138.mp3")
|
||
|
|
||
|
|
||
|
|
||
|
loop = GObject.MainLoop()
|
||
|
loop.run()
|