Use inputstream.adaptive for playback (#25)

This commit is contained in:
Michaël Arnauts 2020-04-20 16:26:16 +02:00 committed by GitHub
parent 78bfae2471
commit 121ea8808f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -6,6 +6,7 @@
<import addon="script.module.pysocks" version="1.6.8" optional="true"/> <import addon="script.module.pysocks" version="1.6.8" optional="true"/>
<import addon="script.module.requests" version="2.22.0"/> <import addon="script.module.requests" version="2.22.0"/>
<import addon="script.module.routing" version="0.2.0"/> <import addon="script.module.routing" version="0.2.0"/>
<import addon="inputstream.adaptive" version="2.4.3"/>
</requires> </requires>
<extension point="xbmc.python.pluginsource" library="addon_entry.py"> <extension point="xbmc.python.pluginsource" library="addon_entry.py">
<provides>video</provides> <provides>video</provides>

View File

@ -4,7 +4,6 @@
from __future__ import absolute_import, division, unicode_literals from __future__ import absolute_import, division, unicode_literals
import logging import logging
import xbmc import xbmc
import xbmcaddon import xbmcaddon
import xbmcgui import xbmcgui
@ -118,7 +117,7 @@ def url_for(name, *args, **kwargs):
def show_listing(title_items, category=None, sort=None, content=None, cache=True): def show_listing(title_items, category=None, sort=None, content=None, cache=True):
""" Show a virtual directory in Kodi """ """Show a virtual directory in Kodi"""
from resources.lib.addon import routing from resources.lib.addon import routing
if content: if content:
@ -200,11 +199,20 @@ def play(stream, title=None, art_dict=None, info_dict=None, prop_dict=None):
if prop_dict: if prop_dict:
play_item.setProperties(prop_dict) play_item.setProperties(prop_dict)
# Setup Inputstream Adaptive
if kodi_version_major() >= 19:
play_item.setProperty('inputstream', 'inputstream.adaptive')
else:
play_item.setProperty('inputstreamaddon', 'inputstream.adaptive')
play_item.setProperty('inputstream.adaptive.manifest_type', 'hls')
play_item.setMimeType('application/vnd.apple.mpegurl')
play_item.setContentLookup(False)
xbmcplugin.setResolvedUrl(routing.handle, True, listitem=play_item) xbmcplugin.setResolvedUrl(routing.handle, True, listitem=play_item)
def get_search_string(heading='', message=''): def get_search_string(heading='', message=''):
""" Ask the user for a search string """ """Ask the user for a search string"""
search_string = None search_string = None
keyboard = xbmc.Keyboard(message, heading) keyboard = xbmc.Keyboard(message, heading)
keyboard.doModal() keyboard.doModal()
@ -265,7 +273,7 @@ class progress(xbmcgui.DialogProgress, object): # pylint: disable=invalid-name,
"""Create and show a progress dialog""" """Create and show a progress dialog"""
if kodi_version_major() < 19: if kodi_version_major() < 19:
lines = message.split('\n', 2) lines = message.split('\n', 2)
line1, line2, line3 = (lines + [None] * (3-len(lines))) line1, line2, line3 = (lines + [None] * (3 - len(lines)))
return super(progress, self).create(heading, line1=line1, line2=line2, line3=line3) return super(progress, self).create(heading, line1=line1, line2=line2, line3=line3)
return super(progress, self).create(heading, message=message) return super(progress, self).create(heading, message=message)
@ -273,7 +281,7 @@ class progress(xbmcgui.DialogProgress, object): # pylint: disable=invalid-name,
"""Update the progress dialog""" """Update the progress dialog"""
if kodi_version_major() < 19: if kodi_version_major() < 19:
lines = message.split('\n', 2) lines = message.split('\n', 2)
line1, line2, line3 = (lines + [None] * (3-len(lines))) line1, line2, line3 = (lines + [None] * (3 - len(lines)))
return super(progress, self).update(percent, line1=line1, line2=line2, line3=line3) return super(progress, self).update(percent, line1=line1, line2=line2, line3=line3)
return super(progress, self).update(percent, message=message) return super(progress, self).update(percent, message=message)