unoplatform/uno · error · NotSupportedException
IStorageFile is not supported
Error message
IStorageFile is not supported
What it means
NotSupportedException thrown by MediaPlayerExtension.SetFileSource on WebAssembly. The WASM media player is HTML <video>-based and only supports Uri sources; file-backed (IStorageFile) sources are explicitly unsupported. Calling SetFileSource on the WASM target always throws.
Source
Thrown at src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs:464
{
if (this.Log().IsEnabled(LogLevel.Debug))
{
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)View on GitHub (pinned to 0418340488)
Solutions
- On WASM, obtain a playable URI (blob URL or remote URL) and use SetUriSource instead of SetFileSource.
- Branch platform-specific source-setting: use StorageFile on desktop, Uri on WASM.
- If you have a local file, create an object URL in JS and pass it as a Uri.
- Avoid calling SetFileSource entirely on WASM; guard with OperatingSystem.IsBrowser()/platform checks.
Example fix
// before — shared code calls SetFileSource
extension.SetFileSource(pickedFile);
// after — branch by platform
#if __WASM__
extension.SetUriSource(new Uri(blobUrl));
#else
extension.SetFileSource(pickedFile);
#endif Defensive patterns
Strategy: validation
Validate before calling
// Do not call SetFileSource on WASM
if (!OperatingSystem.IsBrowser())
extension.SetFileSource(file);
else
throw new PlatformNotSupportedException("Use SetUriSource on WASM"); Type guard
bool SupportsFileSource() => !OperatingSystem.IsBrowser();
Try / catch
try { extension.SetFileSource(file); }
catch (NotSupportedException ex) when (ex.Message.Contains("IStorageFile"))
{ Log.Error("File sources unsupported on WASM — use a Uri"); } Prevention
- Branch source-setting by platform; WASM needs a URI/blob URL.
- Guard SetFileSource calls with OperatingSystem.IsBrowser().
- Use object URLs for local file content on WASM.
When it happens
Trigger: Code path that calls SetFileSource(IStorageFile) on the WASM media extension — e.g. a shared cross-platform codebase that, on WASM, attempts to play from a StorageFile obtained via a file picker.
Common situations: Cross-platform media code that uses StorageFile/FileOpenPicker to pick a local file and feeds it to the media player; porting desktop behavior to WASM where only URIs are playable due to browser sandbox restrictions.
Related errors
- IMediaSource 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/26f6f81cb6a3e334.
Report an issue: GitHub.