2017-06-07, 10:08
PHP Code:
class MyPlayer(xbmc.Player):
duration = 0
playingvideo = False
playlistlen = 0
movie = False
def __init__(self):
xbmclog('Kodi Hue: In MyPlayer.__init__()')
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
xbmclog('Kodi Hue: In MyPlayer.onPlayBackStarted()')
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
self.playlistlen = playlist.size()
self.playingvideo = True
self.duration = self.getTotalTime()
state_changed("started", self.duration)
def onPlayBackPaused(self):
xbmclog('Kodi Hue: In MyPlayer.onPlayBackPaused()')
state_changed("paused", self.duration)
if self.isPlayingVideo():
self.playingvideo = False
def onPlayBackResumed(self):
xbmclog('Kodi Hue: In MyPlayer.onPlayBackResume()')
state_changed("resumed", self.duration)
if self.isPlayingVideo():
self.playingvideo = True
if self.duration == 0:
self.duration = self.getTotalTime()
def onPlayBackStopped(self):
xbmclog('Kodi Hue: In MyPlayer.onPlayBackStopped()')
state_changed("stopped", self.duration)
self.playingvideo = False
self.playlistlen = 0
def onPlayBackEnded(self):
xbmclog('Kodi Hue: In MyPlayer.onPlayBackEnded()')
# If there are upcoming plays, ignore
if self.playlistpos < self.playlistlen-1:
return
self.playingvideo = False
state_changed("stopped", self.duration)
PHP Code:
def run():
player = MyPlayer()
if player is None:
xbmclog('Kodi Hue: In run() could not instantiate player')
return
while not monitor.abortRequested():
if len(hue.ambilight_controller.lights) and not ev.is_set():
startReadOut = False
vals = {}
# live tv does not trigger playbackstart
if player.isPlayingVideo() and not player.playingvideo:
player.playingvideo = True
state_changed("started", player.getTotalTime())
continue
if player.playingvideo: # only if there's actually video
try:
vals = capture.getImage(200)
if len(vals) > 0 and player.playingvideo:
startReadOut = True
if startReadOut:
screen = image.Screenshot(
capture.getImage())
hsv_ratios = screen.spectrum_hsv(
screen.pixels,
hue.settings.ambilight_threshold_value,
hue.settings.ambilight_threshold_saturation,
hue.settings.color_bias,
len(hue.ambilight_controller.lights)
)
for i in range(len(hue.ambilight_controller.lights)):
algorithm.transition_colorspace(
hue, hue.ambilight_controller.lights.values()[i], hsv_ratios[i], )
except ZeroDivisionError:
pass
if monitor.waitForAbort(0.1):
xbmclog('Kodi Hue: In run() deleting player')
del player # might help with slow exit.
Just a few questions to be sure I am thinking of this the right way.
I have to have a myplayer class so that the script know when it has a video so that it will not null out?
PHP Code:
for vals = capture.getimage(200)
# where is the 200 coming from is this the default control for the player?
once I get to screen = image.Screenshot(capture.getImage())
#could I then do
PHP Code:
screenshot = Image.open(screen)
screenshot.save(os.path.join(addondatapath,"screenshot_test")
Or do I need to do some more reading... right now I just want to be abot to see the full image so I know it is working... after that I will then try to add the rest of the parts