public PlayVideoViewModel(HistoryService historyService, IMediaService mediaService, VlcService mediaPlayerService) : base(historyService, mediaService, mediaPlayerService) { _subtitles = new ObservableCollection <Subtitle>(); _subtitlesTracks = new Dictionary <int, string>(); _audioTracks = new Dictionary <int, string>(); #if NETFX_CORE _mouseService = App.Container.Resolve <MouseService>(); #endif _setSubTitlesCommand = new SetSubtitleTrackCommand(); _setAudioTrackCommand = new SetAudioTrackCommand(); _openSubtitleCommand = new OpenSubtitleCommand(); }
public async Task OpenFile(StorageFile file) { if (file == null) { return; } if (string.IsNullOrEmpty(file.Path)) { // It's definitely a stream since it doesn't add a proper path but a FolderRelativeId // WARNING : Apps should use vlc://openstream/?from=url&url= for this matter var mrl = file.FolderRelativeId; var lastIndex = mrl.LastIndexOf("\\", StringComparison.OrdinalIgnoreCase); if (lastIndex != -1) { mrl = mrl.Remove(0, lastIndex + "\\".Length); } await PlayStream(mrl); return; } var token = StorageApplicationPermissions.FutureAccessList.Add(file); var fileType = VLCFileExtensions.FileTypeHelper(file.FileType); if (fileType == VLCFileExtensions.VLCFileType.Video) { await PlayVideoFile(file, token); } else if (fileType == VLCFileExtensions.VLCFileType.Audio) { await PlayAudioFile(file, token); } else if (fileType == VLCFileExtensions.VLCFileType.Subtitle) { if (IsPlaying && PlaybackService.PlayingType == PlayingType.Video) { OpenSubtitleCommand.Execute(file); } } }