mirror of
https://github.com/anxdpanic/plugin.video.youtube.git
synced 2026-05-30 15:52:19 -07:00
Improve support alternative player option
- Bit of a hack
- Now will work with any configured external player using Play with...
- TODO:
- Add option to prefer muxed http streams for players that don't support loading MPEG-DASH manifest
- Split existing use website url option
- Prefer website urls for use with context menu
- Force use of web urls for use with default external player
This commit is contained in:
parent
7eab8fbaf0
commit
ec684269eb
5 changed files with 38 additions and 16 deletions
|
|
@ -33,6 +33,7 @@ VALUE_FROM_STR = {
|
|||
}
|
||||
|
||||
BUSY_FLAG = 'busy'
|
||||
SWITCH_PLAYER_FLAG = 'switch_player'
|
||||
WAIT_FLAG = 'builtin_running'
|
||||
|
||||
__all__ = (
|
||||
|
|
@ -42,6 +43,7 @@ __all__ = (
|
|||
'DATA_PATH',
|
||||
'MEDIA_PATH',
|
||||
'RESOURCE_PATH',
|
||||
'SWITCH_PLAYER_FLAG',
|
||||
'TEMP_PATH',
|
||||
'VALUE_FROM_STR',
|
||||
'WAIT_FLAG',
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
|
||||
from ..constants import paths
|
||||
from ..constants import ADDON_ID, paths
|
||||
|
||||
|
||||
def more_for_video(context, video_id, logged_in=False, refresh=False):
|
||||
|
|
@ -66,7 +66,7 @@ def content_from_description(context, video_id):
|
|||
def play_with(context):
|
||||
return (
|
||||
context.localize('video.play.with'),
|
||||
'Action(SwitchPlayer)'
|
||||
'RunScript({addon_id},action/play_with)'.format(addon_id=ADDON_ID),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
from __future__ import absolute_import, division, unicode_literals
|
||||
|
||||
from .. import AudioItem, DirectoryItem, ImageItem, UriItem, VideoItem
|
||||
from ...constants import SWITCH_PLAYER_FLAG
|
||||
from ...compatibility import xbmc, xbmcgui
|
||||
from ...utils import current_system_version, datetime_parser
|
||||
|
||||
|
|
@ -329,9 +330,19 @@ def video_playback_item(context, video_item, show_fanart=None):
|
|||
settings = context.get_settings()
|
||||
headers = video_item.get_headers()
|
||||
license_key = video_item.get_license_key()
|
||||
is_external = False
|
||||
is_strm = context.get_param('strm')
|
||||
mime_type = None
|
||||
|
||||
if context.get_ui().get_property(SWITCH_PLAYER_FLAG):
|
||||
is_external = True
|
||||
if (settings.alternative_player_web_urls()
|
||||
and not video_item.get_license_key()):
|
||||
is_external = True
|
||||
uri = 'https://www.youtube.com/watch?v={video_id}'.format(
|
||||
video_id=video_item.video_id
|
||||
)
|
||||
|
||||
if is_strm:
|
||||
kwargs = {
|
||||
'path': uri,
|
||||
|
|
@ -349,7 +360,7 @@ def video_playback_item(context, video_item, show_fanart=None):
|
|||
'isPlayable': str(video_item.playable).lower(),
|
||||
}
|
||||
|
||||
if (video_item.use_isa_video()
|
||||
if (not is_external and video_item.use_isa_video()
|
||||
and context.addon_enabled('inputstream.adaptive')):
|
||||
if video_item.use_mpd_video():
|
||||
manifest_type = 'mpd'
|
||||
|
|
@ -559,14 +570,6 @@ def video_listitem(context, video_item, show_fanart=None):
|
|||
uri = video_item.get_uri()
|
||||
context.log_debug('Converting VideoItem |%s|' % uri)
|
||||
|
||||
settings = context.get_settings()
|
||||
|
||||
if (settings.alternative_player_web_urls()
|
||||
and not video_item.get_license_key()):
|
||||
uri = 'https://www.youtube.com/watch?v={video_id}'.format(
|
||||
video_id=video_item.video_id
|
||||
)
|
||||
|
||||
kwargs = {
|
||||
'label': video_item.get_title() or video_item.get_name(),
|
||||
'label2': video_item.get_short_details(),
|
||||
|
|
@ -615,7 +618,7 @@ def video_listitem(context, video_item, show_fanart=None):
|
|||
props['playlist_item_id'] = prop_value
|
||||
|
||||
if show_fanart is None:
|
||||
show_fanart = settings.show_fanart()
|
||||
show_fanart = context.get_settings().show_fanart()
|
||||
image = video_item.get_image()
|
||||
list_item.setArt({
|
||||
'icon': image or 'DefaultVideo.png',
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import re
|
|||
import threading
|
||||
|
||||
from ..compatibility import xbmc
|
||||
from ..constants import BUSY_FLAG
|
||||
from ..constants import BUSY_FLAG, SWITCH_PLAYER_FLAG
|
||||
|
||||
|
||||
class PlayerMonitorThread(threading.Thread):
|
||||
|
|
@ -352,13 +352,24 @@ class PlayerMonitor(xbmc.Player):
|
|||
))
|
||||
self.threads = active_threads
|
||||
|
||||
def onPlayBackStarted(self):
|
||||
if self._ui.get_property(SWITCH_PLAYER_FLAG):
|
||||
self._context.execute('Action(FullScreen)')
|
||||
self._context.execute('Action(SwitchPlayer)')
|
||||
self._context.execute('Action(Stop)')
|
||||
|
||||
def onAVStarted(self):
|
||||
if self._ui.get_property(SWITCH_PLAYER_FLAG):
|
||||
return
|
||||
|
||||
if not self._ui.busy_dialog_active():
|
||||
self._ui.clear_property(BUSY_FLAG)
|
||||
|
||||
playback_json = self._ui.get_property('playback_json')
|
||||
if not playback_json:
|
||||
return
|
||||
self._ui.clear_property('playback_json')
|
||||
self.cleanup_threads()
|
||||
|
||||
playback_json = json.loads(playback_json)
|
||||
try:
|
||||
|
|
@ -370,8 +381,6 @@ class PlayerMonitor(xbmc.Player):
|
|||
self.start_time = None
|
||||
self.end_time = None
|
||||
|
||||
self._ui.clear_property('playback_json')
|
||||
self.cleanup_threads()
|
||||
self.threads.append(PlayerMonitorThread(self,
|
||||
self._provider,
|
||||
self._context,
|
||||
|
|
@ -382,6 +391,9 @@ class PlayerMonitor(xbmc.Player):
|
|||
if not self._ui.busy_dialog_active():
|
||||
self._ui.clear_property(BUSY_FLAG)
|
||||
|
||||
if self._ui.get_property(SWITCH_PLAYER_FLAG):
|
||||
self._ui.clear_property(SWITCH_PLAYER_FLAG)
|
||||
|
||||
self.stop_threads()
|
||||
self.cleanup_threads()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import os
|
|||
import socket
|
||||
|
||||
from .compatibility import parse_qsl, urlsplit, xbmc, xbmcaddon, xbmcvfs
|
||||
from .constants import DATA_PATH, TEMP_PATH, WAIT_FLAG
|
||||
from .constants import DATA_PATH, SWITCH_PLAYER_FLAG, TEMP_PATH, WAIT_FLAG
|
||||
from .context import XbmcContext
|
||||
from .network import get_client_ip_address, httpd_status
|
||||
from .utils import rm_dir, validate_ip_address
|
||||
|
|
@ -337,6 +337,11 @@ def run(argv):
|
|||
xbmc.executebuiltin('Container.Refresh')
|
||||
return
|
||||
|
||||
if action == 'play_with':
|
||||
ui.set_property(SWITCH_PLAYER_FLAG, 'true')
|
||||
xbmc.executebuiltin('Action(Play)')
|
||||
return
|
||||
|
||||
if category == 'config':
|
||||
_config_actions(context, action, params)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue