private async void onDefaultAudioRenderDeviceChanged(object sender, DefaultAudioRenderDeviceChangedEventArgs args) { if (args.Role != AudioDeviceRole.Default || args.Id == AudioDeviceID) { return; } AudioDeviceID = args.Id; // If we don't have an instance yet, no need to fetch the audio client as it will be done upon // instance creation. if (Instance == null) { return; } await DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Always fetch the new audio client, as we always assign it when starting a new playback AudioClient = new AudioDeviceHandler(AudioDeviceID); // But if a playback is in progress, inform VLC backend that we changed device if (MediaPlayer != null) { MediaPlayer.outputDeviceSet(AudioClient.audioClient()); } }); }
private void SetAudioDevice() { var mediaPlayer = MediaPlayer; if (mediaPlayer != null) { AudioDevice = new AudioDeviceHandler(AudioDeviceId); mediaPlayer.outputDeviceSet(AudioDevice.audioClient()); } }
public Task Initialize() { return(DispatchHelper.InvokeInUIThread(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var param = new List <string> { "-I", "dummy", "--no-osd", "--verbose=3", "--no-stats", "--avcodec-fast", "--subsdec-encoding", Locator.SettingsVM.SubtitleEncodingValue == "System" ? "" : Locator.SettingsVM.SubtitleEncodingValue, "--aout=winstore", string.Format("--keystore-file={0}\\keystore", ApplicationData.Current.LocalFolder.Path), }; // So far, this NEEDS to be called from the main thread try { App.RootPage.SwapChainPanel.CompositionScaleChanged += SwapChainPanel_CompositionScaleChanged; App.RootPage.SwapChainPanel.SizeChanged += SwapChainPanel_SizeChanged; Instance = new Instance(param, App.RootPage.SwapChainPanel); Instance?.setDialogHandlers( async(title, text) => await _dialogService.ShowErrorDialog(title, text), async(dialog, title, text, defaultUserName, askToStore) => await _dialogService.ShowLoginDialog(dialog, title, text, defaultUserName, askToStore), async(dialog, title, text, qType, cancel, action1, action2) => await _dialogService.ShowQuestionDialog(dialog, title, text, qType, cancel, action1, action2), (dialog, title, text, intermidiate, position, cancel) => { }, async(dialog) => await _dialogService.CancelCurrentDialog(), (dialog, position, text) => { } ); // Audio device management also needs to be called from the main thread AudioClient = new AudioDeviceHandler(AudioDeviceID); MediaDevice.DefaultAudioRenderDeviceChanged += onDefaultAudioRenderDeviceChanged; PlayerInstanceReady.TrySetResult(Instance != null); } catch (Exception e) { LogHelper.Log("VLC Service : Couldn't create VLC Instance\n" + StringsHelper.ExceptionToString(e)); ToastHelper.Basic(Strings.FailStartVLCEngine); } })); }
public Task Initialize(object o = null) { return(DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var param = new List <string> { "-I", "dummy", "--no-osd", "--verbose=3", "--no-stats", "--avcodec-fast", string.Format("--freetype-font={0}\\NotoSans-Regular.ttf", Windows.ApplicationModel.Package.Current.InstalledLocation.Path), "--subsdec-encoding", Locator.SettingsVM.SubtitleEncodingValue == "System" ? "" : Locator.SettingsVM.SubtitleEncodingValue, "--aout=winstore", string.Format("--keystore-file={0}\\keystore", ApplicationData.Current.LocalFolder.Path), }; // So far, this NEEDS to be called from the main thread try { Instance = new Instance(param, App.RootPage.SwapChainPanel); Instance?.setDialogHandlers( async(title, text) => { await DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { await VLCDialog.WaitForDialogLock(); CurrentDialog = new VLCDialog(title, text); await CurrentDialog.ShowAsync(); }); }, async(dialog, title, text, defaultUserName, askToStore) => { await DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { await VLCDialog.WaitForDialogLock(); CurrentDialog = new VLCDialog(title, text, dialog, defaultUserName, askToStore); await CurrentDialog.ShowAsync(); }); }, async(dialog, title, text, qType, cancel, action1, action2) => { await DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { if (qType == Question.warning) { dialog.postAction(1); return; } await VLCDialog.WaitForDialogLock(); CurrentDialog = new VLCDialog(title, text, dialog, qType, cancel, action1, action2); await CurrentDialog.ShowAsync(); }); }, (dialog, title, text, intermidiate, position, cancel) => { }, async(dialog) => { await DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => CurrentDialog.Cancel()); }, (dialog, position, text) => { }); // Audio device management also needs to be called from the main thread AudioClient = new AudioDeviceHandler(AudioDeviceID); MediaDevice.DefaultAudioRenderDeviceChanged += onDefaultAudioRenderDeviceChanged; PlayerInstanceReady.TrySetResult(Instance != null); } catch (Exception e) { LogHelper.Log("VLC Service : Couldn't create VLC Instance\n" + StringsHelper.ExceptionToString(e)); ToastHelper.Basic(Strings.FailStartVLCEngine); } })); }