def get_next_track(sess_obj):
    next_trackid = xbmc.getInfoLabel("MusicPlayer.(1).Property(spotifytrackid)")
    if next_trackid:
        #Try loading it as a spotify track
        link_obj = link.create_from_string("spotify:track:%s" %next_trackid)
        if link_obj:
            return load_track(sess_obj, link_obj.as_track())

        #Try to parse as a local track
        link_obj = link.create_from_string("spotify:local:%s" %next_trackid)
        if link_obj:
            local_track = link_obj.as_track()
            return load_track(sess_obj, local_track.get_playable(sess_obj))
    else: return None
Exemple #2
0
def get_next_track(sess_obj):
    next_trackid = xbmc.getInfoLabel(
        "MusicPlayer.(1).Property(spotifytrackid)")
    if next_trackid:
        #Try loading it as a spotify track
        link_obj = link.create_from_string("spotify:track:%s" % next_trackid)
        if link_obj:
            return load_track(sess_obj, link_obj.as_track())

        #Try to parse as a local track
        link_obj = link.create_from_string("spotify:local:%s" % next_trackid)
        if link_obj:
            local_track = link_obj.as_track()
            return load_track(sess_obj, local_track.get_playable(sess_obj))
    else:
        return None
    def _get_track_object(self, track_str):

        #Strip the optional extension...
        r = re.compile('\.wav$', re.IGNORECASE)
        track_id = re.sub(r, '', track_str)

        #Try to parse as a track
        link_obj = link.create_from_string("spotify:track:%s" % track_id)
        if link_obj is not None:
            track_obj = link_obj.as_track()
            load_track(self.__session, track_obj)
            return track_obj

        #Try to parse as a local track
        link_obj = link.create_from_string("spotify:local:%s" % track_id)
        if link_obj is not None:
            track_obj = link_obj.as_track()
            load_track(self.__session, track_obj)
            return track_obj

        #Fail if we reach this point
        raise cherrypy.HTTPError(404)
 def _get_track_object(self, track_str):
     
     #Strip the optional extension...
     r = re.compile('\.wav$', re.IGNORECASE)
     track_id = re.sub(r, '', track_str)
     
     #Try to parse as a track
     link_obj = link.create_from_string("spotify:track:%s" % track_id)
     if link_obj is not None:
         track_obj = link_obj.as_track()
         load_track(self.__session, track_obj)
         return track_obj
     
     #Try to parse as a local track
     link_obj = link.create_from_string("spotify:local:%s" % track_id)
     if link_obj is not None:
         track_obj = link_obj.as_track()
         load_track(self.__session, track_obj)
         return track_obj
     
     #Fail if we reach this point
     raise cherrypy.HTTPError(404)
Exemple #5
0
 def _get_track_from_url(self, sess_obj, url):
     
     #Get the clean track if from the url
     path = urlparse(url).path
     r = re.compile('^/track/(.+?)(?:\.wav)?$', re.IGNORECASE)
     mo = r.match(path)
     
     #If we succeed, create the object
     if mo is not None:
         
         #Try loading it as a spotify track
         link_obj = link.create_from_string("spotify:track:%s" % mo.group(1))
         if link_obj is not None:
             return load_track(sess_obj, link_obj.as_track())
     
         #Try to parse as a local track
         link_obj = link.create_from_string("spotify:local:%s" % mo.group(1))
         if link_obj is not None:
             
             #return the autolinked one, instead of the local track
             local_track = link_obj.as_track()
             return load_track(sess_obj, local_track.get_playable(sess_obj))
Exemple #6
0
    def _get_track_from_url(self, sess_obj, url):

        #Get the clean track if from the url
        path = urlparse(url).path
        r = re.compile('^/track/(.+?)(?:\.wav)?$', re.IGNORECASE)
        mo = r.match(path)

        #If we succeed, create the object
        if mo is not None:

            #Try loading it as a spotify track
            link_obj = link.create_from_string("spotify:track:{0}".format(
                mo.group(1)))
            if link_obj is not None:
                return load_track(sess_obj, link_obj.as_track())

            #Try to parse as a local track
            tmpStr = "spotify:local:{0}".format(mo.group(1))
            link_obj = link.create_from_string(tmpStr)
            if link_obj is not None:

                #return the autolinked one, instead of the local track
                local_track = link_obj.as_track()
                return load_track(sess_obj, local_track.get_playable(sess_obj))
Exemple #7
0
 def startTrack(self, stream, trackId):
   with self.trackLock:
     try:
       Log("playback starting: %s"%(trackId))
       self.endTrack_Internal()
       self.stream = stream
       link_obj = link.create_from_string("spotify:track:%s" % trackId)
       if link_obj is not None:
         track_obj = link_obj.as_track()
         self.track = load_track(self.session, track_obj)
         self.status = PlaybackStatus.Streaming
         self.firstFrame = True
         self.session.player_load(track_obj)
         self.session.player_play(True)
         Log("playback started: %s"%(trackId))
         del link_obj
         del track_obj
     except Exception as e:
       Log("Playback Service: Error Starting Track %s"%(e))
       self.endTrack_Internal()