<MediaPlayerElement x:Name="playbaby" Source="{x:Bind ViewModel.soundToPlay, Mode=OneWay, Converter={StaticResource soundSourceConverter}}" AreTransportControlsEnabled="True" Visibility="Collapsed" AutoPlay="True"/>
public class SoundSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
MediaSource source = MediaSource.CreateFromUri(new Uri(value as string));
MediaPlaybackItem item = new MediaPlaybackItem(source);
return item;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
MediaPlaybackItem item = value as MediaPlaybackItem;
string resultSoundURL;
resultSoundURL = item.Source.Uri.ToString();
return resultSoundURL;
}
}
No playback
Playback
The workaround for the above is to return the MediaSource object from the converter, instead of wrapping it in MediaPlaybackItem.
It looks like the bug is in MediaPlayer.InitializeSource() where MediaPlaybackItem is not considered as a possible option.
Nuget Package:
Package Version(s): 1.46.199-dev.2497
Affected platform(s):
Visual Studio
Relevant plugins
Hello, I would like to try fixing this bug!
@rei2hu Thanks! Let us know what you find in this issue!
Guidance for contributors: see the linked PR as a baseline. iOS-specific code and a sample need to be added.
I can push this one over the finish line
My bad for forgetting about this pull request! Thank you for picking it up!
Most helpful comment
I can push this one over the finish line