unoplatform/uno · error · InvalidOperationException
Unsupported media source type
Error message
Unsupported media source type
What it means
InvalidOperationException thrown in InitializeSource (WebAssembly) when _owner.Source is not null but is none of MediaPlaybackList, MediaPlaybackItem, or MediaSource. The WASM media extension only supports those three source types; any other IMediaPlaybackSource implementation falls into the default case.
Source
Thrown at src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs:323
{
_uri = _playlistItems[0];
}
else
{
throw new InvalidOperationException("Playlist Items could not be set");
}
break;
case MediaPlaybackItem item:
_uri = item.Source.Uri;
break;
case MediaSource source:
_uri = source.Uri;
break;
default:
throw new InvalidOperationException("Unsupported media source type");
}
ApplyVideoSource();
Events?.RaiseSourceChanged();
}
catch (global::System.Exception ex)
{
this.Log().Debug($"MediaPlayerElementExtension.InitializeSource({ex.Message})");
OnMediaFailed(ex);
}
}
public void ReInitializeSource()
{
NaturalDuration = TimeSpan.Zero;
if (Position != TimeSpan.Zero)
{View on GitHub (pinned to 0418340488)
Solutions
- Use one of the supported source types: MediaPlaybackList, MediaPlaybackItem, or MediaSource.
- Wrap custom sources in a MediaSource via MediaSource.CreateFromUri / CreateFromStream before assignment.
- Upgrade Uno.UI.MediaPlayer.WebAssembly to match the Uno.UI version so newer source types are handled.
- Log _owner.Source.GetType() before assignment to identify unsupported types in development.
Example fix
// before — unsupported source type player.Source = myCustomSource; // after — wrap in a supported type player.Source = MediaSource.CreateFromUri(myCustomSource.Uri);
Defensive patterns
Strategy: type-guard
Validate before calling
// Ensure source is one of the three supported types
var src = player.Source;
if (src is MediaPlaybackList or MediaPlaybackItem or MediaSource)
extension.InitializeSource();
else
Log.Error($"Unsupported source type: {src?.GetType()}"); Type guard
bool IsSupportedMediaSource(object? src)
=> src is MediaPlaybackList or MediaPlaybackItem or MediaSource; Try / catch
try { extension.InitializeSource(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Unsupported media source type"))
{ Log.Error($"Unsupported source: {player.Source?.GetType()}"); OnMediaFailed(ex); } Prevention
- Use only MediaPlaybackList, MediaPlaybackItem, or MediaSource on WASM.
- Wrap custom sources in MediaSource.CreateFromUri.
- Log source type during development.
When it happens
Trigger: Assigning MediaPlayer.Source to a custom IMediaPlaybackSource implementation, a future/new source type not yet handled, or an object that is not one of the three supported concrete types. (A null Source returns early before the switch, so this is strictly an unrecognized non-null source.)
Common situations: Using a custom IMediaPlaybackSource; a version mismatch where a newer WinUI source type is passed to an older WASM extension; assigning an arbitrary object to Source.
Related errors
- MediaPlayerPresenterExtension must be initialized with a Med
- Playlist Items could not be set
- IStorageFile is not supported
- IMediaSource is not supported
- IRandomAccessStream is not supported
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/0014f6f446635940.
Report an issue: GitHub.