2013-12-06, 11:44
I'm working on giving my addon, Digitally Imported, a much needed overhaul and making it less dependent on regex parsing the sites html.
The current version opens each .pls and extracts the first stream from it, but the optimal solution would of course be to play the first track from the .pls and let the player automatically switch to the next track/stream in case the first one fails.
The current behavior when I add a .pls to the interface using the addDirectoryItem with isFolder=False, is that when I click it, it get's downloaded and opened like a folder, displaying each stream as a seperate item in the menu.
I've tried playing around with the mimetype of the item I'm adding, but it does have the wished effect.
Here's my current WIP version of the addItem() function, hoping someone can point out my stupidity.
Any help or suggestions would be appreciated.
The current version opens each .pls and extracts the first stream from it, but the optimal solution would of course be to play the first track from the .pls and let the player automatically switch to the next track/stream in case the first one fails.
The current behavior when I add a .pls to the interface using the addDirectoryItem with isFolder=False, is that when I click it, it get's downloaded and opened like a folder, displaying each stream as a seperate item in the menu.
I've tried playing around with the mimetype of the item I'm adding, but it does have the wished effect.
Here's my current WIP version of the addItem() function, hoping someone can point out my stupidity.
Code:
# Adds item to XBMC itemlist
def addItem(self, channelTitle, streamUrl, streamDescription, streamBitrate, icon, isNewChannel, totalItems):
if isNewChannel == True: # tart it up a bit if it's a new channel
li = xbmcgui.ListItem(label="[COLOR FF007EFF]" + channelTitle + "[/COLOR]", thumbnailImage=icon)
xbmc.log("New channel found: " + channelTitle, xbmc.LOGERROR)
else:
li = xbmcgui.ListItem(label=channelTitle, thumbnailImage=icon)
li.setProperty("mimetype", 'audio/x-scpls')
li.setInfo(type="Music", infoLabels={"label": channelTitle, "Genre": channelTitle, "Comment": streamDescription,
"Size": (streamBitrate * 1024)})
li.setProperty("IsPlayable", "true")
li.setProperty("IsLive", "true")
player = xbmc.Player(xbmc.PLAYER_CORE_PAPLAYER)
#li.addContextMenuItems('Play', player.play(streamUrl))
xbmcplugin.addDirectoryItem(handle=HANDLE, url=streamUrl, listitem=li, isFolder=False, totalItems=totalItems)
return True
Any help or suggestions would be appreciated.