This commit is contained in:
Ronald Schaten 2021-03-19 15:34:44 +01:00
parent 1af7508eb8
commit 53614c7b78

View File

@ -115,32 +115,50 @@ def get_feature(movieid):
# entry point # entry point
if __name__ == '__main__': if __name__ == '__main__':
movieid = xbmc.getInfoLabel('ListItem.DBID').decode('utf-8')
cinematic_path = ADDON.getSettingString('cinematic_path') cinematic_path = ADDON.getSettingString('cinematic_path')
# collect info about the selected feature movie
movieid = xbmc.getInfoLabel('ListItem.DBID').decode('utf-8')
feature = get_feature(movieid) feature = get_feature(movieid)
print(feature) print(feature)
# let user select one of the JSON programs
programs = list_programs(cinematic_path) programs = list_programs(cinematic_path)
program_file = cinematic_path + show_dialog(programs) program_file = cinematic_path + show_dialog(programs)
program = conduct_program(program_file, feature)
# conduct and show playlist
program = conduct_program(program_file, feature)
print('=== playlist') print('=== playlist')
for entry in program: for entry in program:
print(" * [%s] -- %s" % (entry['type'], entry['data'])) print(" * [%s] -- %s" % (entry['type'], entry['data']))
# close modal movie information window
if xbmc.getCondVisibility('Window.IsVisible(MovieInformation)'): if xbmc.getCondVisibility('Window.IsVisible(MovieInformation)'):
xbmc.executebuiltin('Dialog.Close(MovieInformation)') xbmc.executebuiltin('Dialog.Close(MovieInformation)')
print('=== playing') """
TODO: this is not the intended way of playing back the conducted playlist.
hints for a better implementation are welcome.
the plan is to play each video file in the list separately, so the addon is
able to perform further tasks in between, like controlling home automation
systems. unfortunately, research has to be done in order to find out how
that should be implemented.
"""
# build kodi style playlist
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear() playlist.clear()
for entry in program: for entry in program:
print(" * [%s] -- %s" % (entry['type'], entry['data']))
if entry['type'] == 'video': if entry['type'] == 'video':
playlist.add(entry['data']) playlist.add(entry['data'])
else: else:
# it is planned to implement features other than video playback
# e. g. call scripts in home automation to dim the lights
print(" unable to handle %s yet" % entry['type']) print(" unable to handle %s yet" % entry['type'])
# start playback
xbmc.Player().play(playlist) xbmc.Player().play(playlist)
xbmc.sleep(500) xbmc.sleep(500)
# wait until program is finished
while xbmc.getCondVisibility('Player.HasMedia'): while xbmc.getCondVisibility('Player.HasMedia'):
xbmc.sleep(100) xbmc.sleep(100)
print('=== done playing')