Skip to content

Commit

Permalink
implement heartbeat for transcoder and fixed timelinewatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
DonDavici committed Oct 21, 2014
1 parent d595c12 commit 9de65fc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
42 changes: 39 additions & 3 deletions src/DP_Player.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,23 @@ def startTimelineWatcher(self):

printl("", self, "C")

#===========================================================================
#
#===========================================================================
def pauseService(self):
printl("", self, "S")

if self.playbackType == "1" and self.universalTranscoder:
self.transcoderHeartbeat = eTimer()
self.transcoderHeartbeat.callback.append(self.keepTranscoderAlive)
self.transcoderHeartbeat.start(10000,False)

self.timelineWatcher.stop()

super(DP_Player,self).pauseService()

printl("", self, "C")

#===========================================================================
#
#===========================================================================
Expand All @@ -586,6 +603,10 @@ def unPauseService(self):
self.hide()
self.setSeekState(self.SEEK_STATE_PLAY)

self.transcoderHeartbeat.stop()

self.timelineWatcher.start(5000,False)

printl("", self, "S")
#===========================================================================
#
Expand Down Expand Up @@ -994,6 +1015,16 @@ def handleProgress(self, EOF=False):

printl("", self, "C")

#===========================================================================
#
#===========================================================================
def keepTranscoderAlive(self):
printl("", self, "S")

self.plexInstance.doRequest("http://"+self.server+"/video/:/transcode/universal/ping?session=" + self.transcodingSession)

printl("", self, "C")

#===========================================================================
#
#===========================================================================
Expand Down Expand Up @@ -1062,21 +1093,25 @@ def updateTimeline(self):

self["endingTime"].setText(strftime("%H:%M:%S", endingTime))

print "0"
if self.multiUserServer:
print "a"
try:
print "1"
printl("currentTime: " + str(currentTime), self, "C")
printl("totalTime: " + str(totalTime), self, "C")

urlPath = self.server + "/:/timeline?containerKey=/library/sections/onDeck&key=/library/metadata/" + self.id + "&ratingKey=" + self.id

seekState = self.seekstate
print seekState
sleep(2)

if seekState == self.SEEK_STATE_PAUSE:
print "2"
printl( "Movies PAUSED time: %s secs of %s @ %s%%" % ( currentTime, totalTime, progress), self,"D" )
urlPath += "&state=paused&time=" + str(currentTime*1000) + "&duration=" + str(totalTime*1000)

elif seekState == self.SEEK_STATE_PLAY :
print "3"
printl( "Movies PLAYING time: %s secs of %s @ %s%%" % ( currentTime, totalTime, progress),self,"D" )
urlPath += "&state=playing&time=" + str(currentTime*1000) + "&duration=" + str(totalTime*1000)

Expand All @@ -1085,8 +1120,9 @@ def updateTimeline(self):

# todo add stopped here if needed
#urlPath += "&state=stopped&time=" + str(currentTime*1000) + "&duration=" + str(totalTime*1000)

print "4"
self.plexInstance.doRequest(urlPath)
print "5"

except Exception, e:
printl("exception: " + str(e), self, "E")
Expand Down
7 changes: 2 additions & 5 deletions src/DP_PlexLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,13 +2029,10 @@ def playLibraryMedia(self, myId, url):
if not (self.g_transcode == "true" ):
self.setAudioSubtitles(self.streams)

multiUserServer = False
# multiuser works only if the server is compatible
self.setServerDetails()
if self.g_serverVersion >= "0.9.8.0" and self.g_multiUser:
multiUserServer = True

printl("multiUserServer (version): " + str(multiUserServer),self,"I")
printl("multiUserServer (version): " + str(self.g_multiUser) + "(" + self.g_serverVersion + ")",self,"D")

printl("PLAYURL => " + playurl, self, "I")
printl("RESUME => " + str(resume), self, "I")
Expand All @@ -2046,7 +2043,7 @@ def playLibraryMedia(self, myId, url):
playerData["resumeStamp"] = resume
playerData["server"] = self.server
playerData["id"] = myId
playerData["multiUserServer"] = multiUserServer
playerData["multiUserServer"] = self.g_multiUser
playerData["playbackType"] = self.serverConfig_playbackType
playerData["connectionType"] = self.serverConfig_connectionType
playerData["localAuth"] = self.serverConfig_localAuth
Expand Down

0 comments on commit 9de65fc

Please sign in to comment.