unoplatform/uno · error · NotSupportedException

IRandomAccessStream is not supported

Error message

IRandomAccessStream is not supported

What it means

NotSupportedException thrown by MediaPlayerExtension.SetStreamSource on WebAssembly. The WASM player is HTML <video>-based and does not accept IRandomAccessStream sources directly; only Uri sources are supported. Any call to SetStreamSource throws.

Source

Thrown at src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs:470

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

	public void StepBackwardOneFrame()

View on GitHub (pinned to 0418340488)

Solutions

  1. On WASM, convert the stream to a Blob/object URL in JS and call SetUriSource with that URL.
  2. Branch by platform to avoid SetStreamSource on WASM.
  3. Guard the call site with OperatingSystem.IsBrowser().
  4. Prefer remote URIs for WASM media playback.

Example fix

// before — shared stream playback
extension.SetStreamSource(randomAccessStream);

// after — branch by platform
#if __WASM__
    var blobUrl = await StreamToBlobUrlAsync(randomAccessStream);
    extension.SetUriSource(new Uri(blobUrl));
#else
    extension.SetStreamSource(randomAccessStream);
#endif
Defensive patterns

Strategy: validation

Validate before calling

// Do not call SetStreamSource on WASM
if (!OperatingSystem.IsBrowser())
    extension.SetStreamSource(stream);
else
    throw new PlatformNotSupportedException("Use SetUriSource with a blob URL on WASM");

Type guard

bool SupportsStreamSource() => !OperatingSystem.IsBrowser();

Try / catch

try { extension.SetStreamSource(stream); }
catch (NotSupportedException ex) when (ex.Message.Contains("IRandomAccessStream"))
{ Log.Error("Stream sources unsupported on WASM — use a blob/object URL"); }

Prevention

When it happens

Trigger: Calling SetStreamSource(IRandomAccessStream) on the WASM media extension — e.g. feeding an InMemoryRandomAccessStream or a file stream to the player from shared code.

Common situations: Cross-platform code that plays from an in-memory or file stream; porting stream-based playback from desktop/UWP to WASM where browsers require a URL/blob.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/4a01d7f618ef2779. Report an issue: GitHub.