def media_length(self, service_item): """ Loads and starts a media item to obtain the media length :param service_item: The ServiceItem containing the details to be played. """ media_info = MediaInfo() media_info.volume = 0 media_info.file_info = QtCore.QFileInfo(service_item.get_frame_path()) # display = controller.preview_display suffix = '*.%s' % media_info.file_info.suffix().lower() used_players = get_media_players()[0] player = self.media_players[used_players[0]] if suffix not in player.video_extensions_list and suffix not in player.audio_extensions_list: # Media could not be loaded correctly critical_error_message_box( translate('MediaPlugin.MediaItem', 'Unsupported Media File'), translate('MediaPlugin.MediaItem', 'File %s not supported using player %s') % (service_item.get_frame_path(), used_players[0])) return False media_data = MediaInfoWrapper.parse(service_item.get_frame_path()) # duration returns in milli seconds service_item.set_media_length(media_data.tracks[0].duration) return True
def media_length(service_item): """ Uses Media Info to obtain the media length :param service_item: The ServiceItem containing the details to be played. """ media_info = MediaInfo() media_info.volume = 0 media_info.file_info = QtCore.QFileInfo(service_item.get_frame_path()) media_data = MediaInfoWrapper.parse(service_item.get_frame_path()) # duration returns in milli seconds service_item.set_media_length(media_data.tracks[0].duration) return True
def media_length(self, service_item): """ Loads and starts a media item to obtain the media length :param service_item: The ServiceItem containing the details to be played. """ media_info = MediaInfo() media_info.volume = 0 media_info.file_info = QtCore.QFileInfo(service_item.get_frame_path()) # display = controller.preview_display suffix = '*.%s' % media_info.file_info.suffix().lower() used_players = get_media_players()[0] player = self.media_players[used_players[0]] if suffix not in player.video_extensions_list and suffix not in player.audio_extensions_list: # Media could not be loaded correctly critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported Media File'), translate('MediaPlugin.MediaItem', 'File %s not supported using player %s') % (service_item.get_frame_path(), used_players[0])) return False media_data = MediaInfoWrapper.parse(service_item.get_frame_path()) # duration returns in milli seconds service_item.set_media_length(media_data.tracks[0].duration) return True