Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinUI MediaPlayerElement #5172

Closed
Tracked by #2292
Fernand-Delavy opened this issue Jun 11, 2021 · 73 comments
Closed
Tracked by #2292

WinUI MediaPlayerElement #5172

Fernand-Delavy opened this issue Jun 11, 2021 · 73 comments
Labels

Comments

@Fernand-Delavy
Copy link

I need MediaPlayer on WinUI or Reunion for Windows

On the page :
https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.mediaplayerelement?view=winrt-20348

I read : Equivalent WinUI class: Microsoft.UI.Xaml.Controls.MediaPlayerElement.

if using Microsoft.UI.Xaml.Controls.MediaPlayerElement;

But MediaPlayerElement is not present on :

WinUI UWP, WinUI for Desktop , Project Reunion 0.5.7 and 0.8.0 with .NET 5

What is wrong ? How to use MediaPlayerElelemnt ?

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jun 11, 2021
@StephenLPeters
Copy link
Contributor

MediaPlayerElement isn't currently supported in Winui3,

@MikeHillberg @codendone or @Austin-Lamb to weigh in on the plan for it.

@StephenLPeters StephenLPeters added the team-Rendering Issue for the Rendering team label Jun 15, 2021
@codendone
Copy link
Contributor

See the WinUI 3.0 Feature Roadmap for the latest status on plans, including Media Controls. We currently do not have a specific release timeline for MediaPlayerElement.

@maxkatz6
Copy link
Contributor

maxkatz6 commented Jul 2, 2021

I wonder if it will include MediaElement or will it be removed as previously deprecated control.

@DarrylDreiling-Sphero
Copy link

It would be pretty helpful for us to have the MediaPlayerElement available to WinUI applications.

We use video content in our educational app to help users learn and complete their school activities, so Media Player support would be very helpful. Rather than sending students out of the app to a browser to view the video content, we’d like to have them view their content inside the app while doing their programming work.

We also believe the MediaPlayerElement would allow us to swap out our large library of sounds (which are mono, low bit-rate .wav files), for higher fidelity stereo .mp3 files. This would help us reduce our app install size as well. The Sound Player we are currently using doesn't have a way for us to detect when a sound is done playing, the MediaPlayerElement does.

Overall, better video playback would ensure that our Windows app is competitive with the other versions of our app on iOS, macOS, Android, and ChromeOS, and better ensure the Windows app is a viable solution for our ~200,000 MAU during the school season.

@qJake
Copy link

qJake commented Sep 11, 2021

I wanted to port my WPF app to WinUI 3 which relies heavily on video playback. This is very disappointing. Please add support for this!

@erikvanappeldoorn
Copy link

I contribute to an UWP app with background audio streaming (radio). Would be nice to convert the app to WinUI 3, so no media support would be a show stopper.

@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Sep 20, 2021
@tesar-tech
Copy link

I would like to update my Video Detail Player to WinUI 3 in the near future. This kind of blocks me. The MediaPlayerElement in UWP evolved in pretty useful control I have to say, it's shame to leave it behind (But I also understand, it's not easy to port it).

@ianier
Copy link

ianier commented Oct 17, 2021

I would like to update my Video Detail Player to WinUI 3 in the near future.

Same goes for my app Chronotron.
Is it possible to mix and match UWP/WinUI3 controls? (e.g. using the old Windows.UI.Xaml.MediaPlayerElement in a WinUI 3 UWP app?)

@agenne
Copy link

agenne commented Dec 3, 2021

We urgently need the Control MediaPlayerElement or MediaElement! The roadmap says it will come in a future release, but we need to know when (Q1, Q2?). We would very much like to switch our UWP app to WinUI3 because we urgently need WebView2, but as long as there is no MediaElement, we cannot make the switch.

@HermanEldering
Copy link

For me this issue is also problematic since it is not possible to use XAML Islands in WPF with .NET 5/6 and WinUI3 doesn't support MediaPlayerElement. So other than creating/using a third party media control I think the only solutions are to use either .NET Core 3.1 or UWP? Which both are end-of-life.

@agenne
Copy link

agenne commented Jan 26, 2022

Microsoft, please tell us, will you offer the MediaControls at all? More than half a year is invested in the acrylic features. Who needs that? Would it be possible to know how much longer we have to wait? Unbelievable!

@stefffdev
Copy link

stefffdev commented Jan 27, 2022

You can load the video in a WebView2 and use the HTML5 video API via JavaScript interaction.

@agenne
Copy link

agenne commented Jan 27, 2022

You can load the video in a WebView2 and use the HTML5 video API via JavaScript interaction.

That's a possibility if playing videos is a marginal feature. We have a digital signage system where this is one of the core features...
In addition, there are problems in memory management with WebView2 that can only be solved with WorkAround's.

@HermanEldering
Copy link

You can load the video in a WebView2 and use the HTML5 video API via JavaScript interaction.

For me this is probably also not a solution because I create an overlay using a IBasicVideoEffect.

@ianier
Copy link

ianier commented Jan 27, 2022

For me this is probably also not a solution because I create an overlay using a IBasicVideoEffect.

Yes, audio and video effects are a must have, at least for me.

@stefffdev
Copy link

For me this is probably also not a solution because I create an overlay using a IBasicVideoEffect.

Yes, audio and video effects are a must have, at least for me.

Never tried it but maybe you could implement custom effects in JavaScript as well and trigger them from within your .NET app.

@tesar-tech
Copy link

tesar-tech commented Jan 27, 2022

Never tried it but maybe you could implement custom effects in JavaScript as well and trigger them from within your .NET app.

Yeah, or we can try to write the whole app in some other technology than c# and xaml. ToTalLy ViAbLe oPtioN...
"Fck you in particular UWP developers!" No feature parity in platform you invested in, and even not enough feedback!

@ianier
Copy link

ianier commented Jan 28, 2022

Yeah, or we can try to write the whole app in some other technology than c# and xaml. ToTalLy ViAbLe oPtioN... "Fck you in particular UWP developers!" No feature parity in platform you invested in, and even not enough feedback!

Indeed. Quoting myself from microsoft/WindowsAppSDK#1055 (reply in thread):
"Otherwise, if the cost of moving ahead is rewriting most of the app, I'd rather do it on a platform that shows better commitment to its developers."

@agenne
Copy link

agenne commented Jan 28, 2022

This is exactly where Microsoft finally has to say honestly if and when the important controls (MediaPlayerElement, InkCanvas and Win2D) will be made available. Not making any statements is very disrespectful to the community.

@zipswich
Copy link

zipswich commented Feb 2, 2022

This is the only remaining showstopper for our primary app that relies on MediaPlayerElement.

@pwillies
Copy link

We are in a similar situation to many on this thread. We want to move up to WebView2, but our app also has a video/audio playing component. So - WinUI 2.8 (with WebView2) is not released - and with no clear timeframe on release. And WinUI 3.0 has WebView2, but is missing MediaPlayerElement etc. - and no clear timeframe on release.

@nikolayvpavlov
Copy link

Looking at the number of commits and active contributors draws a dark shadow over my heart. For such a project to succeed, there must be a big team working actively on it. Now, WinUI 3 looks like a hobbist project. MAUI gets more love even in the newsletters, while WinUI 3 is nowhere to be seen.

@ianier
Copy link

ianier commented Feb 18, 2022

WinUI 3 is nowhere to be seen

I keep saying Microsoft abandoned UWP way too early. Perhaps they underestimated the work to be done to get WinUI 3 to feature-parity, or just decided that the few of us developing UWP apps should be "sacrificed".

@KPixel
Copy link

KPixel commented Feb 18, 2022

In all fairness, UWP still works just fine as-is. They just decided that adding more features to it (esp support for .NET 5+) would be way too much work, which is hard to evaluate unless you understand these technologies at the deepest level.

To get back on topic, I am also really surprised and disappointed that they haven't provided a precise roadmap for the MediaPlayerElement. There is likely a big hurdle to overcome, but we don't even know what that is.

@brabebhin
Copy link

@castorix
Copy link

castorix commented May 14, 2022

I just tested the Media Engine and it seems to work very fine
I tested in C# on Windows 10, in Frame-server mode with DXGI or in classic Rendering mode,
It is atm the best Video Player that I could test with WinUI 3 (I tested WMP, Direct Show, ...)

WinUI3_MediaEngine

@MuleaneEve
Copy link

@castorix Have you tried this simple MediaPlayerElement?

It doesn't have all the features built-in yet, but I think it is the best solution in the long term.

@castorix
Copy link

@castorix Have you tried this simple MediaPlayerElement?

Yes, I had tried, but it has the known resizing problem of the SwapChainPanel when scale > 100%
By using CreateSwapChainForHwnd , then resizing the target surface from any XAML control, I don't have this problem with the Media Engine or any Direct2D content

@PierreHenriKT
Copy link

PierreHenriKT commented May 14, 2022

That issue was resolved a couple of weeks ago. Feel free to test it.

(Edit: There is still an issue when the window is small, though...)

@castorix
Copy link

That issue was resolved a couple of weeks ago. Feel free to test it.
(Edit: There is still an issue when the window is small, though...)

Yes, I re-tested and have (a bit of) flickering on resizing with small size (and also some crashes on longer videos (Windows 10 21H1), on seeking for example)

@nikolayvpavlov
Copy link

@castorix , can you please provide a sample how to use this Media Engine from C#?

@brabebhin
Copy link

brabebhin commented May 17, 2022

Media Engine is essentially the engine behind the UWP MediaPlayer class. It cannot be trivially used in C#. If you put the MediaPlayer class in frame server mode, you obtain the same result. There are examples on how to do that on microsoft docs.
The problem is that it doesn't support subtitles.

@castorix
Copy link

castorix commented May 17, 2022

The problem is that it doesn't support subtitles.

I did not test all ME interfaces, but I could draw a text on the DXGI surface, just after IMFMediaEngine::TransferVideoFrame
So subtitles could theoretically be drawn, with the right timing...
(I will post a C# code sample soon, but I'm actually doing quick tests with "dirty" code... (I'm adding buttons atm, not ready yet...))
Test (with GDI on IDXGISurface1) :
WinUI3_MediaEngine_Text

@brabebhin
Copy link

Basically, yes.
If you use the MediaPlayer class in frame server mode, it will tell you when to render subtitles.

@nikolayvpavlov
Copy link

nikolayvpavlov commented May 19, 2022

@PierreHenriKT , is there a way to set the current position of the media from code?

@PierreHenriKT
Copy link

It is a replica of the UWP MediaPlayerElement, so you can use (most of) the same features. For the position, refer to this documentation.

@castorix
Copy link

castorix commented May 19, 2022

Basically, yes. If you use the MediaPlayer class in frame server mode, it will tell you when to render subtitles.

Apparently, subtitles seem to be managed with IMFTimedText and associated interfaces
I will test asap... although it looks like a bit complicated...

@castorix
Copy link

castorix commented Jun 3, 2022

@castorix , can you please provide a sample how to use this Media Engine from C#?

I just uploaded a sample : WinUI3_MediaEngine
I tested various things, like Frame capture, which were more complicated that I thought... so , there are probably a few bugs in this test...
I added Subtitles, which work, but partially : I did not find a way to get styles (italic, bold, ...) with
IMFTimedText* interfaces (I tested for example with Terminator 2 subtitles, which should be in italic at beginning...)

@brabebhin
Copy link

brabebhin commented Jun 3, 2022

I also have a semi working approach to subtitles that use the winRT interfaces, but positioning is really difficult to get working correctly with it comes to all the wanky stuff that SSA supports. The testing work alone is going to take months for an uncoordinated open source project.

I still very much hope that Microsoft sees the light and releases a proper Mediaplayerelement.

@eshvatskyi
Copy link

I'm using LibVLC + WriteableBitmap, as a temp solution

@castorix
Copy link

I just uploaded a sample : WinUI3_MediaEngine

I had to modify the SwapChain and the method for FullScreen because of update 1.1.0 (with the new black/white background added, apparently for flickering problem...)

@emceelovin
Copy link

I'm using LibVLC + WriteableBitmap, as a temp solution

I downloaded LibVLC also as the base for creating a media player inside my application as well. Haven't had much time to finish it though. Seems like a solid solution. When I was reading the docs, it looks like you can pass it an HWND(for Win32) and other native window targets and it'll render the media for you. Awesome IMO.

@alfamizar
Copy link

alfamizar commented Sep 2, 2022

@emceelovin, @eshvatskyi
Hi, can you guys show how do you extract bytes that are writting than in to the WriteableBitmap, please?

@PierreHenriKT
Copy link

PierreHenriKT commented Sep 7, 2022

Apparently, MediaPlayerElement was just added to WinUI 3 (in the Windows App SDK version 1.2 Preview 1).

That's a pleasant surprise!

Edit: I just tested it. It works well, except for some TransportControls buttons that cause the app to crash. Maybe they aren't yet implemented.
Also, the FullWindow and CompactOverlay buttons are gone. I guess they must now be implemented manually.

@codendone
Copy link
Contributor

@PierreHenriKT If you haven't done so, please log a new issue for the crashes you're experiencing with some of the TransportControls. Thanks!

Regarding FullWindow and CompactOverlay, these will not be supported in 1.2. Those buttons and APIs have been removed until they are implemented in a future release.

@PierreHenriKT
Copy link

@codendone Issue logged.

Thanks for the explanation for FullWindow and CompactOverlay.

@JPDelprat
Copy link

Hello,

I am successful in readin a mpeg-dash stream with play ready protection with UWP code (MediaPlayerElement / AdaptiveMediaSource).

With the same code using WinUI3 (last experimental version), I get a "SourceNotSupported" exception.

Are there any differences between WinUI3 and UWP implementations ? Do I miss something ?

Thanks

@brabebhin
Copy link

It is probably just bugged.
There were a lot of bugs last time I checked.

@PierreHenriKT
Copy link

With the release of the Win App SDK 1.2, I think we can close this issue :)

@Fernand-Delavy
Copy link
Author

Yes you can close this issue, thanks

@PierreHenriKT
Copy link

@Fernand-Delavy You are the one who opened this issue, so you can close it : There is a button for that next to the "Comment" button..

@Hanzalah-Adalan
Copy link

OMG finally :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests