WPF MediaElement video won't play after being hidden in storyboard - wpf

I'll start of by describing the problem, and then follow up with details about the process I'm going though.
Problem:
I'm having an issue where I'm playing a MediaElement on one storyboard and then setting the same MediaElement to hidden in another. After having the MediaElement set to hidden, I'm unable to replay the video portion of that storyboard again (non-MediaElement animations still happen.) Videos are WMVs encoded in VC-1 at 10,000 Kbps at a resolution of 1560x1004 and provided alongside the project as relative assets.
Details:
I'm working on a Kiosk application which makes use of a large number of videos combined with some graphical effects for real-time animation. Presently I'm creating storyboards using Blend, layering the videos for playback in the desired sequence. Below details two sample storyboard from the page:
Open performs the following:
Set's meOpen's visibility to 100%, Visible
Set's meIn's visibility to Hidden at 1 second (masking the start of meOpen)
Starts playing meOpen at 0:00.900.
Before playing the Close storyboard the Open storyboard is played, and the system waits for user input to continue. Once Close is triggered, the following happens:
meOpen - A MediaElement that has it's visibility set to 'Hidden' at 1 second
meClose - A MediaElement that is the desired video to play. I have it starting slightly before meOpen is hidden to mask the first frame 'black frame' while the element is loading the video
The rest of the items is just fading visibility of overlay elements.
The storyboard works for running through the video; however, if I try and play the Open storyboard a second time, meOpen does not play.
Thanks

Related

Is WPF MediaElement good for my task

I know WPF MediaElement has lots of bugs, but my project is quite simple:
I have two big video files, 500 mb each - same visuals, with different rendered texts - for 2 different languages.
WPF buttons on top of those videos:
'language' - switch visibility of each video, depending on language;
'product' - scroll forth/back to the required time in both videos simultaneously.
So - all this project does - it plays two video files 24 hours and scrolls both files to reqiured time marks on button click, and shows/hides each video depending on 'language' button click. It does not reload those video files, neither load new ones.
Currently I have this project done with WPFMediaKit. But the problem is - for some reason it has somewhat own time handling. Say I tell it to stop at 23rd second and rewind to 11th - it stops at 24-25 and then rewinds to 11th. I guess its related to its DX renderer.
So my question is - can WPF MediaElement play 2 video files and scroll/rewind both, simultaneously, without freezing/breaking whatever, for 24 hours? TIA

WPF Seamless video play back

I'm working on a project right now where we are in need of seamless video transition between multiple videos in a WPF application.
A second monitor is being used as a media player, events are being sent to the screen to fire off videos, the video position is then being used to fire events back according to the video hitting specific intervals. The project is using a PRISM so the events are being fired by it's Event Aggregator.
The issue is finding a way of playing Videos in WPF that will accommodate for buffering between videos. I don't have code examples for methods tried but I have attempted to do this using.
The native WPF Media Element. This was very buggy and most certainly not user friendly. Bad play back and huge gaps between media files.
WPFMediaKit This is probably the best solution so far, video play back is fine with two issues. The media screen stops playing videos at it seems random times and the control goes black. And the transition between videos is about half a second of black.
Hosting AxWindowsMediaPlayer in a WindowsFormsHost. Play back is great but there is a huge gap between videos, even when running a playlist (This does not happen in Windows Media player so there could be something we are missing.) also as the control is hosted in a WindowsFormsHost I'm not sure if it is possible to keep(Bind) the videos position, and the position event does not appear to be caught.
GMF Play - Seems to have the same issues as WPFMediaKit except the seen is collapsed rather than the screen going black during transitions.
Edit
Media Player Example
Media Element Setup
private void CreateMediaKitElement()
{
WpfMediaKit.BeginInit();
WpfMediaKit.Stretch = Stretch.Fill;
WpfMediaKit.LoadedBehavior = WPFMediaKit.DirectShow.MediaPlayers.MediaState.Manual;
WpfMediaKit.MediaEnded += WpfMediaKit_MediaEnded;
WpfMediaKit.Volume = 0;
WpfMediaKit.EndInit();
}
private void PlayVideo(string uri, IEnumerable<Interval> intervals)
{
// Stop the current Audio track if a new video is being shown.
AudioElement.Stop();
WpfMediaKit.Stop();
// WpfMediaKit = null;
//Try recreating Element
WpfMediaKit = new MediaUriElement();
CreateMediaKitElement();
WpfMediaKit.Source = new Uri(uri, UriKind.Relative);
WpfMediaKit.Play();
}
So my question, does anyone know of or have an example of a method to play videos in WPF with a seamless transition between videos?
Thanks in advance,
Oli

Transition animiation that shows parts of both pages at the same time?

In my Phone 7 app, I'm currently using the Silverlight Toolkit's transition service to implement transition animations when the user navigates between pages. It's working. But I don't like these animations because they always consist of two phases: the first phase shows an animation between the current page and the background, and the second one an animation between the background and the next page. It seems that most Phone 7 applications have this kind of animations.
What I would like to have instead is a direct animation from one page to another so that during the animation parts of both pages are visible. For a slide animation for example, the old page would move to the left and directly reveal the new page underneath. During the animation, the screen is split: the left part show less and less of the old page while the right part shows more and more of the new page.
How can I achieve that? Is a Silverlight storyboard able to do this?
I did similar research for calendar control and ended with the next solution:
before navigating to the other month, copy current control content
into underlying rectangle (render it to image and use as ImageBrush
to fill rectangle);
set current control content Opacity to 0 so that only underlying rectangle is visible;
create new control content (while it is still with opacity = 0);
start animation. Animation is performed for underlying rectangle and control content opacities and for their RenderTransforms.
when animation completes, clear underlying rectangle Fill property.
It's the idea. All storyboards can be defined in xaml, but animation handling requires some code.
I'm not sure whether it is applicable to your case, maybe you need something like Book control.

Silverlight MediaElement

Am new to Silverlight. Have added the MediaElement and Placed the Media file(.wmv format) with .xap file . ,Media Element is not visible . I want to know how can i Make it Visible on the application run...
Short answer is that a MediaElement is not a Media Player. At least no in the sense of all the UI goodness of buttons or dials, sliders and the like. For that you'll need to biuld, burrow or buy the player.
One place to start is with Microsoft Expression Encoder, that ships the complete source for a full featured, skinable player.
If you just need to play the media element without all of a media player functionalities (start, stop, next, pause and other buttons plus a progress bar), you can simply set it's property AutoPlay to true and it will start as soon as the page is loaded.
If you want some more control over the clip playback, you can call MediaElement instance methods like Play, Stop, Pause from your code behind.

Smooth Video Transitions for WPF

I'm using VB.net 2010 and WPF 4. I need to have a smooth transition between two videos played on the mediaelement. I absolutely cannot use anything that requires me to use a winhost in the WPF window, as that will make my project impossible (since the video is full screen, and the controls are over the video)
Basically, I need for the video to play through, and then smoothly go to another video specified in code behind. I cannot splice the two videos together - they must be separate.
How do I have the videos transition smoothly, with no "blink"?
I'm guessing without testing here. You're probably going to need some CPU cores and a good video card.
If you have the memory, use two MediaElements.
Queue up both videos, one on each element.
Set the opacity of the second one to completely transparent. They're UIElements so this should work...
Use timers of some kind keyed from the start of playback on the first one so that you get an event a couple of seconds before playback ends.
With that event delegate, start the video in the second MediaElement, animate the first one's opacity to zero while simultaneously animating the second one to fully opaque.
If you need to do it again, set up the timer again and make sure your delegate animates things the other way.

Resources