diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 75973f389..13b7c848f 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -173,6 +173,7 @@ class ItemCapabilities(object): HasNotes = 20 HasThumbnails = 21 HasMetaData = 22 + CanStream = 23 def get_text_file_string(text_file_path): diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index a6281ec82..f0fe16b63 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -229,7 +229,10 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): display = self._define_display(controller) if controller.is_live: # if this is an optical device use special handling - if service_item.is_capable(ItemCapabilities.IsOptical): + if service_item.is_capable(ItemCapabilities.CanStream): + is_valid = self._check_file_type(controller, display) + controller.media_info.media_type = MediaType.Stream + elif service_item.is_capable(ItemCapabilities.IsOptical): log.debug('video is optical and live') path = service_item.get_frame_path() (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path) @@ -249,7 +252,10 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): controller.media_info.start_time = service_item.start_time controller.media_info.end_time = service_item.end_time elif controller.preview_display: - if service_item.is_capable(ItemCapabilities.IsOptical): + if service_item.is_capable(ItemCapabilities.CanStream): + is_valid = self._check_file_type(controller, display) + controller.media_info.media_type = MediaType.Stream + elif service_item.is_capable(ItemCapabilities.IsOptical): log.debug('video is optical and preview') path = service_item.get_frame_path() (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(path) @@ -353,6 +359,12 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): :param controller: First element is the controller which should be used :param display: Which display to use """ + if controller.media_info.media_type == MediaType.Stream: + self.resize(display, self.vlc_player) + if self.vlc_player.load(display, None): + self.current_media_players[controller.controller_type] = self.vlc_player + controller.media_info.media_type = MediaType.Video + return True for file in controller.media_info.file_info: if file.is_file: suffix = '*%s' % file.suffix.lower() diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 9db106e33..b3d5d24e2 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -147,14 +147,15 @@ class VlcPlayer(MediaPlayer): Load a video into VLC :param output_display: The display where the media is - :param file: file to be played + :param file: file to be played or None for live streaming :return: """ vlc = get_vlc() log.debug('load vid in Vlc Controller') controller = output_display volume = controller.media_info.volume - path = os.path.normcase(file) + if file: + path = os.path.normcase(file) # create the media if controller.media_info.media_type == MediaType.CD: if is_win(): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 594552b4a..4ccc55d36 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -175,7 +175,11 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): return False filename = str(item.data(QtCore.Qt.UserRole)) # Special handling if the filename is a optical clip - if filename.startswith('optical:'): + if filename == 'live': + service_item.processor = 'vlc' + service_item.title = filename + service_item.add_capability(ItemCapabilities.CanStream) + elif filename.startswith('optical:'): (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(filename) if not os.path.exists(name): if not remote: @@ -258,11 +262,11 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): """ # TODO needs to be fixed as no idea why this fails # media.sort(key=lambda file_path: get_natural_key(file_path.name)) - file_name = "Live Stream" + file_name = translate('MediaPlugin.MediaItem', 'Live Stream') item_name = QtWidgets.QListWidgetItem(file_name) item_name.setIcon(UiIcons().video) - item_name.setData(QtCore.Qt.UserRole, 0) - item_name.setToolTip("Live Stream feed") + item_name.setData(QtCore.Qt.UserRole, 'live') + item_name.setToolTip(translate('MediaPlugin.MediaItem', 'Show Live Stream')) self.list_view.addItem(item_name) for track in media: track_str = str(track)