{"record":{"id":"0014f6f446635940","repo":"unoplatform/uno","slug":"unsupported-media-source-type","errorCode":null,"errorMessage":"Unsupported media source type","messagePattern":"Unsupported media source type","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs","lineNumber":323,"sourceCode":"\t\t\t\t\t{\n\t\t\t\t\t\t_uri = _playlistItems[0];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new InvalidOperationException(\"Playlist Items could not be set\");\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MediaPlaybackItem item:\n\t\t\t\t\t_uri = item.Source.Uri;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MediaSource source:\n\t\t\t\t\t_uri = source.Uri;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new InvalidOperationException(\"Unsupported media source type\");\n\t\t\t}\n\n\t\t\tApplyVideoSource();\n\t\t\tEvents?.RaiseSourceChanged();\n\t\t}\n\t\tcatch (global::System.Exception ex)\n\t\t{\n\n\t\t\tthis.Log().Debug($\"MediaPlayerElementExtension.InitializeSource({ex.Message})\");\n\t\t\tOnMediaFailed(ex);\n\t\t}\n\t}\n\n\tpublic void ReInitializeSource()\n\t{\n\t\tNaturalDuration = TimeSpan.Zero;\n\t\tif (Position != TimeSpan.Zero)\n\t\t{","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/MediaPlayerExtension.cs#L305-L341","documentation":"InvalidOperationException thrown in InitializeSource (WebAssembly) when _owner.Source is not null but is none of MediaPlaybackList, MediaPlaybackItem, or MediaSource. The WASM media extension only supports those three source types; any other IMediaPlaybackSource implementation falls into the default case.","triggerScenarios":"Assigning MediaPlayer.Source to a custom IMediaPlaybackSource implementation, a future/new source type not yet handled, or an object that is not one of the three supported concrete types. (A null Source returns early before the switch, so this is strictly an unrecognized non-null source.)","commonSituations":"Using a custom IMediaPlaybackSource; a version mismatch where a newer WinUI source type is passed to an older WASM extension; assigning an arbitrary object to Source.","solutions":["Use one of the supported source types: MediaPlaybackList, MediaPlaybackItem, or MediaSource.","Wrap custom sources in a MediaSource via MediaSource.CreateFromUri / CreateFromStream before assignment.","Upgrade Uno.UI.MediaPlayer.WebAssembly to match the Uno.UI version so newer source types are handled.","Log _owner.Source.GetType() before assignment to identify unsupported types in development."],"exampleFix":"// before — unsupported source type\nplayer.Source = myCustomSource;\n\n// after — wrap in a supported type\nplayer.Source = MediaSource.CreateFromUri(myCustomSource.Uri);","handlingStrategy":"type-guard","validationCode":"// Ensure source is one of the three supported types\nvar src = player.Source;\nif (src is MediaPlaybackList or MediaPlaybackItem or MediaSource)\n    extension.InitializeSource();\nelse\n    Log.Error($\"Unsupported source type: {src?.GetType()}\");","typeGuard":"bool IsSupportedMediaSource(object? src)\n    => src is MediaPlaybackList or MediaPlaybackItem or MediaSource;","tryCatchPattern":"try { extension.InitializeSource(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unsupported media source type\"))\n{ Log.Error($\"Unsupported source: {player.Source?.GetType()}\"); OnMediaFailed(ex); }","preventionTips":["Use only MediaPlaybackList, MediaPlaybackItem, or MediaSource on WASM.","Wrap custom sources in MediaSource.CreateFromUri.","Log source type during development."],"tags":["media-player","wasm","source","uno-platform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}