Using custom video Effects with MediaElement - c#

I have an application that uses MediElement to play videos and provides it with a custom video effects implemented in C++\CX via MediaElement.AddVideoEffect method.
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.mediaelement.addvideoeffect
And it works just fine. But there is a bit of a problem, - When user hits the "Pause" button, MediaElement stops calling ProccessFrame method of the video effects I attach. Which leads to the situation, when user can tweak his effect whilst video is playing, but cannot do it on Pause.
So basically, I'm wondering if there is a workaround.
Thank you for the time and effort.
Kind regards.

Related

Audio stuttering while scrolling (C# WebBrowser)

I have a WinForms WebBrowser control in a WPF WindowsFormsHost, but I've verified the problem in straight WinForms as well as several different computers.
What happens is whenever a webpage is playing music and I start scrolling the page the audio freezes and repeats the same short sample over and over again. One of the most pronounced sites that exhibits this is Google Play Music.
Is there anything I can do to mitigate this problem?
Try enabling GPU rendering for your WebBrowser control via FEATURE_GPU_RENDERING feature. Here is how to do it, and there's a bunch of other features to play with.

Play Background Sound and Sound Effect in Windows Phone 8

I have researched a lot on playing sounds for Windows Phone 8 devices and found multiple solutions but they don't quite match my case.
What I need : I'm writing an app (C#+XAML) that uses a file as background sound (must be active while navigating the whole app), and also to be able to play sound effects.
What are the issues :
For background sound I could use the BackgroundAudio Agent, but it doesn't meet my requirements because I want the sound to be played only in the background of my app, and to stop if my app closes or is not active.
For sound effects - I tried MediaElement which is okay, but I couldn't manage to make it somehow play while I am navigating the whole app. Media closes if I leave that page - I guess I could use this for the sound effects trick. Also, there's the SoundEffect which is not quite a good solution since it can play only .wav files... I could use it for sound effects only but not background sound (big sized files).
So, how should I proceed to play background sound (only inside my app) if I choose MediaElement/SoundEffect to play a sound effect in the app. I need a solution that would allow me to play 2 sounds at once (background and sound effect) and the background sound to be played only while the app runs (is active)...
So far I am confused and managed only to solve the sound effects issue.
Any suggestions are greatly appreciated.
The issue you are seeing with your MediaElement is that you are defining it to be part of the application page and it stops playing as soon as it disappears off of the Visual Tree (i.e. after OnNavigatedFrom).
If you define a MediaElement to be "visible" as part of the application frame, audio will keep playing while your app is active (you will need to handle deactivation events, naturally).
If you do this MediaElement should work for your "background audio".
Be aware you can only have one single active MediaElement playing media in your app, however you should be able to use SoundEffect for your sound effects.
Update:
To put your MediaElement in a frame, you will need to create a custom PhoneApplicationFrame class/XAML, add the MediaElement to that XAML, and refer to your custom frame in App.xaml.cs.
// Do not add any additional code to this method
private void InitializePhoneApplication()
{
if (phoneApplicationInitialized)
return;
// Create the frame but don't set it as RootVisual yet; this allows the splash
// screen to remain active until the application is ready to render.
RootFrame = new MyCustomPhoneApplicationFrame();
RootFrame.Navigated += CompleteInitializePhoneApplication;
See this Dzone article for more about Frame/Page in Windows Phone.
In practice, MediaElement is has some gotchas like the visual tree requirement. There are ways to get around it, but they are not optimal. I would suggest scrapping using MediaElement and use XAudio2 instead. It is native so default usage would be in c++, but you can also use SharpDX to access this framework from C#.
The advantage of XAudio2 is that you would not need to worry about sound dropping out when navigating around since it is not dependent on the UI. Another advantage is you could have one SourceVoice for handling your background audio, and other SourceVoices for handling sound effect playback. This all fits well within the model of usage the framework was designed for.

MediaElement seems to disable lock screen when playing a video

I am working on an application that plays a video using the MediaElement component. Now, I would like that if the user is idle, the lock screen appears, as configured by the user in the Settings of the device.
If I don't play a video, the lock screen indeed appears. But, when a video is playing no lock screen appears. I cannot find any information on this.
Currently I set the idle detection modes like this:
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;
I am a bit lost now. The only solution I can think of is running a timer myself and stop the video playback after a certain time. (but there seems to be no API calls to receive the configured lock timeout.)
Any suggestions are welcome, thanks.
One workaround for you would be to enable running under the lockscreen. Then in the obscured even you could stop the mediaplayer. Not ideal, but it might serve your purposes.

Best silverlight video technique for playing movies

I was wondering if anyone can give me some insight on what is the prefered best option for playing a video in a Silverlight MediaElement. Right now I am using a direct link to a .wmv file on an mms server but the location is inconsistent and occasionaly locks up my ui when I try to load the video.
When this happens the storyboard animations that take place that is supposed present the video freeze up until the video is loaded then the animation catches up and jumps to the end. Looks really bad.
I have the option for smooth streaming as well. Just curious if there is a prefered best way to present video?
At a minimum you should not be starting your storyboards until the MediaOpened event has fired. And yes, smooth streaming would probably present the best user experience.

DirectShow EVR resizing window problem

So I've been looking into the world of media playback for windows and I've started making a C# Media Player using DirectShow. I started off using the VRM-7 windowed video renderer and it was brilliant except it had a couple of small problems (multi monitors, fullscreen). But after some research I found that it's deprecated and I should be using VRM9.
So I changed it to use VRM9 windowless then found out that was an old post rofl >_< so finally I'm using Vista/Win7 (or XP .net 3) Enhanced Video Renderer (EVR) which is apparently the most up to date Microsoft video renderer and has all the flashy performance/quality things added to it. (tbh I haven't noticed any difference but maybe I need a blue-ray or HQ video to notice it).
With using EVR everything is working fine except resizing the video. Its really laggy/choppy/teary and probably something to do with its frame queueing mechanism.
To demonstrate my problem
open up windows media player classic.
View -> Options -> Playback -> output
Chose the "EVR" DirectShow Video renderer
Now restart wmp class and play a video, while it's playing click and drag a corner to resize it. You'll notice its horribly laggy. This is the exact same problem i am having.
But if you chose "EVR Custom Pres. **" or EVR Sync **" resizing works beautifully! So i tried googling around for anything about EVR resizing issues and how to fix it but i couldn't believe how little i could find. I'm guessing "Custom Pres." stands for "Custom Presenter" which sounds like they made their own.
Also you'll notice on the right hand size when you swap between EVR and the other EVR's the Resizer drop down on the right greys out.
So basically I wan't to know how I can fix this retarded resizing problem and is there any decent documentation out there? There is a fair bit for VMR7/9 but not much for EVR. I downloaded the DirectX SDK which apparently has samples but it was a waste of 500mb of bandwidth as it had nothing relevant.
Perhaps there is some way to force it not queueing up frames if that is the problem?
If you want code say the word and I'll paste some in. But it's really quite simple and nothing much happens, i'm convinced it's a problem with the EVR renderer.
EDIT: Oh and one other thing, what does VLC use? If you go into vlc options and change the renderer to anything but default, they all suck. So is it using VMR7? Or its own?
I need to write my own Custom Presenter, which from the looks of http://msdn.microsoft.com/en-us/library/bb530107(VS.85).aspx is a relatively big task.
Guess i'll look at the sample and try to go from there

Categories