unoplatform/uno · error · NotSupportedException
IMediaSource is not supported
Error message
IMediaSource is not supported
What it means
NotSupportedException thrown by MediaPlayerExtension.SetMediaSource on WebAssembly. The WASM media extension does not implement IMediaSource-based playback (only Uri sources are supported via SetUriSource). Any call to SetMediaSource throws unconditionally.
Source
Thrown at src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs:467
this.Log().Debug($"MediaPlayerExtension.Play(): Player was not prepared");
}
}
}
catch (global::System.Exception ex)
{
if (this.Log().IsEnabled(LogLevel.Debug))
{
this.Log().Debug($"MediaPlayerExtension.Play(): Failed {ex}");
}
OnMediaFailed(ex);
}
}
public void SetFileSource(IStorageFile file)
=> throw new NotSupportedException($"IStorageFile is not supported");
public void SetMediaSource(IMediaSource source)
=> throw new NotSupportedException($"IMediaSource is not supported");
public void SetStreamSource(IRandomAccessStream stream)
=> throw new NotSupportedException($"IRandomAccessStream is not supported");
public void SetSurfaceSize(Size size)
=> throw new NotSupportedException($"SetSurfaceSize is not supported");
public void SetUriSource(Uri uri)
{
if (this.Log().IsEnabled(LogLevel.Debug))
{
this.Log().Debug($"MediaPlayerExtension.SetUriSource({uri})");
}
if (_player is not null)
{
_player.Source = uri.OriginalString;
}View on GitHub (pinned to 0418340488)
Solutions
- On WASM, resolve a Uri from your source and call SetUriSource instead.
- Branch source-setting by platform to avoid SetMediaSource on WASM.
- Guard the call site with a platform/runtime check (OperatingSystem.IsBrowser()).
- Upgrade the add-in; if IMediaSource support is added later, match versions.
Example fix
// before — shared call
extension.SetMediaSource(mediaSource);
// after — use Uri on WASM
#if __WASM__
extension.SetUriSource(mediaSource.Uri);
#else
extension.SetMediaSource(mediaSource);
#endif Defensive patterns
Strategy: validation
Validate before calling
// Do not call SetMediaSource on WASM
if (!OperatingSystem.IsBrowser())
extension.SetMediaSource(source);
else
throw new PlatformNotSupportedException("Use SetUriSource on WASM"); Type guard
bool SupportsMediaSource() => !OperatingSystem.IsBrowser();
Try / catch
try { extension.SetMediaSource(source); }
catch (NotSupportedException ex) when (ex.Message.Contains("IMediaSource"))
{ Log.Error("IMediaSource unsupported on WASM — resolve a Uri"); } Prevention
- Resolve a Uri from your source and use SetUriSource on WASM.
- Guard SetMediaSource with a platform check.
- Keep add-in versions aligned in case support is added.
When it happens
Trigger: Calling SetMediaSource(IMediaSource) on the WASM media extension — e.g. shared code that builds an IMediaSource and passes it cross-platform.
Common situations: Cross-platform media initialization that uses IMediaSource abstractions; porting desktop behavior where IMediaSource is supported to WASM.
Related errors
- IStorageFile is not supported
- IRandomAccessStream is not supported
- SetSurfaceSize is not supported
- MediaPlayerPresenterExtension must be initialized with a Med
- Playlist Items could not be set
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/0c3f330e27cca4ce.
Report an issue: GitHub.