Uno: MediaPlayerElement doesn't support setting MediaPlaybackItem as Source

Created on 19 Aug 2019  路  5Comments  路  Source: unoplatform/uno

How to reproduce it (as minimally and precisely as possible)

<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;
    }
}

Current behavior

No playback

Expected behavior

Playback

Notes

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.

Environment

Nuget Package:

Package Version(s): 1.46.199-dev.2497

Affected platform(s):

  • [x] iOS
  • [x] Android
  • [ ] WebAssembly
  • [ ] Windows
  • [ ] Build tasks

Visual Studio

  • [ ] 2017 (version: )
  • [ ] 2019 (version: )
  • [ ] for Mac (version: )

Relevant plugins

  • [ ] Resharper (version: )

Anything else we need to know?

good first issue hacktoberfest help wanted kinbug projecmedia

Most helpful comment

I can push this one over the finish line

All 5 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ali-YousefiTelori picture Ali-YousefiTelori  路  4Comments

MartinZikmund picture MartinZikmund  路  3Comments

JanabiSoft picture JanabiSoft  路  3Comments

jeromelaban picture jeromelaban  路  3Comments

PylotLight picture PylotLight  路  3Comments