diff --git a/app/VLC.Core/Services/RunTime/PlaybackService.cs b/app/VLC.Core/Services/RunTime/PlaybackService.cs index 9e3d68393e1ec9359861738fb44d969324c4ed5f..410f5ca919713714c995b0b5c6ec5e5264648536 100644 --- a/app/VLC.Core/Services/RunTime/PlaybackService.cs +++ b/app/VLC.Core/Services/RunTime/PlaybackService.cs @@ -48,6 +48,7 @@ namespace VLC.Services.RunTime public event Playing Playback_MediaPlaying; public event Paused Playback_MediaPaused; public event Opening Playback_Opening; + public event Action<PlayingType> PlayingTypeChanged; public event Action OnPlaylistEndReached; public event Action OnPlaylistChanged; @@ -147,7 +148,18 @@ namespace VLC.Services.RunTime } - public PlayingType PlayingType { get; set; } + private PlayingType _playingType; + public PlayingType PlayingType + { + get { return _playingType; } + set + { + if (_playingType == value) + return; + _playingType = value; + PlayingTypeChanged?.Invoke(value); + } + } public MediaState PlayerState { get; private set; } @@ -333,9 +345,6 @@ namespace VLC.Services.RunTime CurrentMedia = new Media(Instance, mrl_fromType.Item2, mrl_fromType.Item1); } - // Default to audio playback, and switch to video when a video track is encountered - PlayingType = PlayingType.Music; - // Hardware decoding CurrentMedia.addOption(!Locator.SettingsVM.HardwareAccelerationEnabled ? ":avcodec-hw=none" : ":avcodec-hw=d3d11va"); CurrentMedia.addOption(!Locator.SettingsVM.HardwareAccelerationEnabled ? ":avcodec-threads=0" : ":avcodec-threads=1"); @@ -700,6 +709,9 @@ namespace VLC.Services.RunTime private void OnPlaying() { + // If no video tracks were detected so far, assume we're playing music + if (PlayingType == PlayingType.NotPlaying) + PlayingType = PlayingType.Music; PlayerStateChanged(this, MediaState.Playing); } diff --git a/app/VLC.Core/ViewModels/MainVM.cs b/app/VLC.Core/ViewModels/MainVM.cs index bdafb4db0898bc0e68a9a67f993b968016a47deb..08eb28432e93ffcc7950a00858294aa4e72a26b5 100644 --- a/app/VLC.Core/ViewModels/MainVM.cs +++ b/app/VLC.Core/ViewModels/MainVM.cs @@ -114,7 +114,7 @@ namespace VLC.ViewModels // - The current page Locator.NavigationService.ViewNavigated += (_, __) => NotifyCommandBarDisplayModeChanged(); // And whether the media is a video or not - Locator.PlaybackService.Playback_MediaSet += (_) => NotifyCommandBarDisplayModeChanged(); + Locator.PlaybackService.PlayingTypeChanged += (_) => NotifyCommandBarDisplayModeChanged(); } private async void NotifyCommandBarDisplayModeChanged() diff --git a/app/VLC.Core/ViewModels/MediaPlaybackViewModel.cs b/app/VLC.Core/ViewModels/MediaPlaybackViewModel.cs index 9be6109d2649cfb4b9bc064961b707b0bd781ae2..04d14640a5e4e848b273d322ca1baeb75fe4160f 100644 --- a/app/VLC.Core/ViewModels/MediaPlaybackViewModel.cs +++ b/app/VLC.Core/ViewModels/MediaPlaybackViewModel.cs @@ -262,7 +262,7 @@ namespace VLC.ViewModels Locator.PlaybackService.OnPlaylistChanged += PlaylistService_OnPlaylistChanged; Locator.PlaybackService.OnPlaylistEndReached += OnPlaylistEndReached; Locator.PlaybackService.OnRepeatChanged += OnRepeatChanged; - Locator.PlaybackService.Playback_MediaParsed += OnMediaParsed; + Locator.PlaybackService.PlayingTypeChanged += OnPlayingTypeChanged; } private async void OnRepeatChanged(bool obj) @@ -286,7 +286,7 @@ namespace VLC.ViewModels }); } - private async void OnMediaParsed(ParsedStatus status) + private async void OnPlayingTypeChanged(PlayingType pType) { await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Normal, () => {