Commit 2505042e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaPlaybackVM: Don't rely on ParsedChanged event to monitor PlayingType

This fixes CommandBar display for some playbacks on windows phone
parent d51527e1
......@@ -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);
}
......
......@@ -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()
......
......@@ -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, () =>
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment