{"record":{"id":"26f6f81cb6a3e334","repo":"unoplatform/uno","slug":"istoragefile-is-not-supported","errorCode":null,"errorMessage":"IStorageFile is not supported","messagePattern":"IStorageFile is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs","lineNumber":464,"sourceCode":"\t\t\t{\n\t\t\t\tif (this.Log().IsEnabled(LogLevel.Debug))\n\t\t\t\t{\n\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)","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs#L446-L482","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — shared code calls SetFileSource\nextension.SetFileSource(pickedFile);\n\n// after — branch by platform\n#if __WASM__\n    extension.SetUriSource(new Uri(blobUrl));\n#else\n    extension.SetFileSource(pickedFile);\n#endif","handlingStrategy":"validation","validationCode":"// Do not call SetFileSource on WASM\nif (!OperatingSystem.IsBrowser())\n    extension.SetFileSource(file);\nelse\n    throw new PlatformNotSupportedException(\"Use SetUriSource on WASM\");","typeGuard":"bool SupportsFileSource() => !OperatingSystem.IsBrowser();","tryCatchPattern":"try { extension.SetFileSource(file); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"IStorageFile\"))\n{ Log.Error(\"File sources unsupported on WASM — use a Uri\"); }","preventionTips":["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."],"tags":["media-player","wasm","storagefile","unsupported","uno-platform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}