Closed emako closed 2 years ago
I wrote a demo to reproduce this problem: https://github.com/lindexi/lindexi_gd/tree/af15cde4b0628c2744a8b8eac14a791e2d4f7b54/KufayunurharnaLuragaruker
MediaPlayer is a wrapper around the Windows Media Player which, to my knowledge, only supports path and URLs. You could extract the file from the assembly, save it to a file, play the file and then delete the file. This is not ideal but for small files (Which I suppose is your case since it doesn't really make sense to embed large file inside the assembly), it should be fast enough.
@ThomasGoulet73 How about throw an exception when input the pack://
uri?
MediaPlayer is a wrapper around the Windows Media Player which, to my knowledge, only supports path and URLs. You could extract the file from the assembly, save it to a file, play the file and then delete the file. This is not ideal but for small files (Which I suppose is your case since it doesn't really make sense to embed large file inside the assembly), it should be fast enough.
Does MediaPlayer intend to append the API that passes the Stream
parameter for opening file?
Good catch. It will raise the MediaFailed event.
You were faster than me 😄. Here's the code that throws when using pack for reference: https://github.com/dotnet/wpf/blob/4af440108d50958a2ac3e3f67a454aa0cd142e5c/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs#L844-L855
Does MediaPlayer intend to append the API that passes the Stream parameter for opening file?
This repo is probably not the right place to ask this question since Windows Media Player is probably maintained by the Windows team. I would recommend using third-party solutions which might support using a Stream
(VLC based player might support it).
Try VLC or extract the file from the assembly to fix problem.
Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.
Problem description:
MediaPlayer cant play the uri startswith
pack://...
. such asActual behavior:
UriSchemePack
type uri cant be played using MediaPlayer.Expected behavior:
Minimal repro: