WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

MediaPlaybackItem.AudioTracks.SelectedIndex is not respected if set too early

Open benstevens48 opened this issue 1 year ago • 0 comments

Describe the bug

MediaPlaybackItem.AudioTracks.SelectedIndex is not respected if set before the media player playbacksesssion get past the opening state.

Steps to reproduce the bug

Create a media source from a video file with multiple audio tracks, create a media playback item from it, then set the MediaPlaybackItem.AudioTracks.SelectedIndex to something > 0, assuming the tracks have loaded. Note you can also call source.OpenAsync then set it if the tracks are not loaded straight away, or even listen to the tracks changed event then set it there. The selected index is set correctly. However, when you come to play the media with a MediaPlayer, the track with index 0 is still played. The workaround is to wait until the media player playbacksession is in the paused state before setting the selected audio track index. However, this is inconvenient and relies on having access to the media player, when really the selected track is a property of the media source.

Expected behavior

MediaPlaybackItem.AudioTracks.SelectedIndex should be respected.

Screenshots

No response

NuGet package version

None

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

Bug is in MediaPlaybackItem/MediaPlayer, does not require WinAppSdk.

benstevens48 avatar May 27 '24 15:05 benstevens48