2012-02-23, 03:13
I'm very new to python (4 days and lotsa googling), and am nearing completion on my first plugin for the audio service Hypem.
I'm building a directory of 20 items, all of which get queued when one is selected. I'm having trouble registering onPlayBackStopped, or other player state commands such as onPlayBackEnded.
The commands for that shouldn't be too hard, but I can't get the onPlayBackStopped to work. I started by testing with some logging commands.
I assume the onPlayBackStopped is not being called because the player being called isn't the one specified for this class.
Here's the code specifying my directory listing for items:
Is there a way to pass a specific player name to the items being played in this list? (Assuming that is the issue.)
And here is my code calling the addir just for completion sake.
I've seen a number of other users having issues with getting the status of the player - most end up writing a set of nested loops with sleep(x) commands. I tried some of them as well, and my directories just never populated. If anyone could provide any help I would much appreciate it!
I'm building a directory of 20 items, all of which get queued when one is selected. I'm having trouble registering onPlayBackStopped, or other player state commands such as onPlayBackEnded.
The commands for that shouldn't be too hard, but I can't get the onPlayBackStopped to work. I started by testing with some logging commands.
Code:
player = XBMCPlayer()
class XBMCPlayer( xbmc.Player ):
def _init_( self, *args ):
pass
def onPlayBackStopped( self ):
xbmc.log( "Playback Stopped" )
I assume the onPlayBackStopped is not being called because the player being called isn't the one specified for this class.
Here's the code specifying my directory listing for items:
Code:
def addLink(name,url,iconimage):
#xbmcplugin.setContent(handle=int(sys.argv[1]), content="audio" )
ok=True
liz=xbmcgui.ListItem(label=name,thumbnailImage=iconimage, path=url)
liz.setProperty("mimetype", 'audio/mpeg')
liz.setInfo('Music', {"title": name })
liz.setProperty('IsPlayable','true')
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=False)
return ok
Is there a way to pass a specific player name to the items being played in this list? (Assuming that is the issue.)
And here is my code calling the addir just for completion sake.
Code:
def INDEX(url,page):
feedurl = url + str(page) + apikey
page=int(page)+1
req = urllib2.Request(feedurl)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
raw_json=response.read()
response.close()
parsed_json=json.loads(raw_json)
del parsed_json['version']
print 'Parsed_Json_output'
decoded_json =_decode_dict(parsed_json)
print 'decoded_json_output'
playlist = sortedDictValues1(decoded_json)
print 'Sorted_playlist_output'
#xbmcplugin.setContent(handle=int(sys.argv[1]), content="audio" )
for x in playlist:
artist = str(x['artist'])
title = str(x['title'])
puburl = x['stream_pub']
thumb = x['thumb_url_large']
name = artist + ' - ' + title
addLink(name,puburl,thumb)
def mainmenu():
addDir('Main Menu...',url,None,'',int(page))
def nextmenu():
nextmenu = addDir('Next Page...',url,1,'',int(page))
if len(playlist) < 1:
CATEGORIES()
elif len(playlist) < 19:
mainmenu()
else:
nextmenu()
mainmenu()
I've seen a number of other users having issues with getting the status of the player - most end up writing a set of nested loops with sleep(x) commands. I tried some of them as well, and my directories just never populated. If anyone could provide any help I would much appreciate it!