+ # Play a song
+ def playSong(self, item):
+ global playTimer
+ global player
+ if item != None:
+ songid = item.getProperty('songid')
+ stream = groovesharkApi.getSubscriberStreamKey(songid)
+ url = stream['url']
+ item.setPath(url)
+ xbmc.log("Grooveshark playing: " + url)
+ xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
+ # Wait for play then start time
+ seconds = 0
+ while seconds < STREAM_MARKING_TIME:
+ try:
+ if player.isPlayingAudio() == True:
+ if playTimer != None:
+ playTimer.cancel()
+ songMarkTime = 0
+ duration = int(item.getProperty('duration'))
+ playTimer = PlayTimer(1, markSong, duration, [songid, duration])
+ playTimer.start()
+ break
+ except: pass
+ time.sleep(1)
+ seconds = seconds + 1
+ else:
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Unable to play song, 1000, ' + thumbDef + ')')
+
+ # Make a song directory item
+ def songItem(self, songid, name, album, artist, coverart, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL):
+ songImg = self._get_icon(coverart, 'song-' + str(songid) + "-image")
+ if int(trackLabelFormat) == NAME_ALBUM_ARTIST_LABEL:
+ trackLabel = name + " - " + album + " - " + artist
+ else:
+ trackLabel = artist + " - " + album + " - " + name
+ duration = self._getSongDuration(songid)
+ item = xbmcgui.ListItem(label = trackLabel, thumbnailImage=songImg, iconImage=songImg)
+ item.setInfo( type="music", infoLabels={ "title": name, "album": album, "artist": artist, "duration": duration} )
+ item.setProperty('mimetype', 'audio/mpeg')
+ item.setProperty("IsPlayable", "true")
+ item.setProperty('songid', str(songid))
+ item.setProperty('coverart', songImg)
+ item.setProperty('title', name)
+ item.setProperty('album', album)
+ item.setProperty('artist', artist)
+ item.setProperty('duration', str(duration))
+
+ return item
+
+ # Next page of songs
+ def songPage(self, page, trackLabelFormat, playlistid = 0, playlistname = ''):
+ self._add_songs_directory([], trackLabelFormat, page, playlistid = playlistid, playlistname = playlistname)
+
+ # Make a playlist from an album