{"record":{"id":"0c3f330e27cca4ce","repo":"unoplatform/uno","slug":"imediasource-is-not-supported","errorCode":null,"errorMessage":"IMediaSource is not supported","messagePattern":"IMediaSource is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs","lineNumber":467,"sourceCode":"\t\t\t\t\tthis.Log().Debug($\"MediaPlayerExtension.Play(): Player was not prepared\");\n\t\t\t\t}\n\t\t\t}\n\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}","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs#L449-L485","documentation":"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.","triggerScenarios":"Calling SetMediaSource(IMediaSource) on the WASM media extension — e.g. shared code that builds an IMediaSource and passes it cross-platform.","commonSituations":"Cross-platform media initialization that uses IMediaSource abstractions; porting desktop behavior where IMediaSource is supported to WASM.","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."],"exampleFix":"// before — shared call\nextension.SetMediaSource(mediaSource);\n\n// after — use Uri on WASM\n#if __WASM__\n    extension.SetUriSource(mediaSource.Uri);\n#else\n    extension.SetMediaSource(mediaSource);\n#endif","handlingStrategy":"validation","validationCode":"// Do not call SetMediaSource on WASM\nif (!OperatingSystem.IsBrowser())\n    extension.SetMediaSource(source);\nelse\n    throw new PlatformNotSupportedException(\"Use SetUriSource on WASM\");","typeGuard":"bool SupportsMediaSource() => !OperatingSystem.IsBrowser();","tryCatchPattern":"try { extension.SetMediaSource(source); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"IMediaSource\"))\n{ Log.Error(\"IMediaSource unsupported on WASM — resolve a Uri\"); }","preventionTips":["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."],"tags":["media-player","wasm","imediasource","unsupported","uno-platform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}