{"record":{"id":"4a01d7f618ef2779","repo":"unoplatform/uno","slug":"irandomaccessstream-is-not-supported","errorCode":null,"errorMessage":"IRandomAccessStream is not supported","messagePattern":"IRandomAccessStream is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs","lineNumber":470,"sourceCode":"\t\t}\n\t\tcatch (global::System.Exception ex)\n\t\t{\n\t\t\tif (this.Log().IsEnabled(LogLevel.Debug))\n\t\t\t{\n\t\t\t\tthis.Log().Debug($\"MediaPlayerExtension.Play(): Failed {ex}\");\n\t\t\t}\n\t\t\tOnMediaFailed(ex);\n\t\t}\n\t}\n\n\tpublic void SetFileSource(IStorageFile file)\n\t\t=> throw new NotSupportedException($\"IStorageFile is not supported\");\n\n\tpublic void SetMediaSource(IMediaSource source)\n\t\t=> throw new NotSupportedException($\"IMediaSource is not supported\");\n\n\tpublic void SetStreamSource(IRandomAccessStream stream)\n\t\t=> throw new NotSupportedException($\"IRandomAccessStream is not supported\");\n\n\tpublic void SetSurfaceSize(Size size)\n\t\t=> throw new NotSupportedException($\"SetSurfaceSize is not supported\");\n\n\tpublic void SetUriSource(Uri uri)\n\t{\n\t\tif (this.Log().IsEnabled(LogLevel.Debug))\n\t\t{\n\t\t\tthis.Log().Debug($\"MediaPlayerExtension.SetUriSource({uri})\");\n\t\t}\n\n\t\tif (_player is not null)\n\t\t{\n\t\t\t_player.Source = uri.OriginalString;\n\t\t}\n\t}\n\n\tpublic void StepBackwardOneFrame()","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs#L452-L488","documentation":"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.","triggerScenarios":"Calling SetStreamSource(IRandomAccessStream) on the WASM media extension — e.g. feeding an InMemoryRandomAccessStream or a file stream to the player from shared code.","commonSituations":"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.","solutions":["On WASM, convert the stream to a Blob/object URL in JS and call SetUriSource with that URL.","Branch by platform to avoid SetStreamSource on WASM.","Guard the call site with OperatingSystem.IsBrowser().","Prefer remote URIs for WASM media playback."],"exampleFix":"// before — shared stream playback\nextension.SetStreamSource(randomAccessStream);\n\n// after — branch by platform\n#if __WASM__\n    var blobUrl = await StreamToBlobUrlAsync(randomAccessStream);\n    extension.SetUriSource(new Uri(blobUrl));\n#else\n    extension.SetStreamSource(randomAccessStream);\n#endif","handlingStrategy":"validation","validationCode":"// Do not call SetStreamSource on WASM\nif (!OperatingSystem.IsBrowser())\n    extension.SetStreamSource(stream);\nelse\n    throw new PlatformNotSupportedException(\"Use SetUriSource with a blob URL on WASM\");","typeGuard":"bool SupportsStreamSource() => !OperatingSystem.IsBrowser();","tryCatchPattern":"try { extension.SetStreamSource(stream); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"IRandomAccessStream\"))\n{ Log.Error(\"Stream sources unsupported on WASM — use a blob/object URL\"); }","preventionTips":["Convert streams to blob/object URLs on WASM and use SetUriSource.","Guard SetStreamSource with a platform check.","Prefer remote URIs for WASM playback."],"tags":["media-player","wasm","stream","irandomaccessstream","unsupported","uno-platform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}