I'm trying to make a text reader for my WP7.
I'm using a mediaElement in my reader.
at first every time the app read something, the MediaPlayer stopped, as I later discovered that is how it is designed.
Then I tried to try and trick the system, by using
mediaElement1.Stop();
mediaElement1.SetSource(isolatedStorageFileStream);
FrameworkDispatcher.Update();
MediaPlayer.Pause();
mediaElement1.Play();
if (mpState != MediaState.Stopped)
{ MediaPlayer.Resume(); }
now comes the wierd part,
when I use the reader once, it reads and the music seems to run without any pause, as I wanted, but when I use the reader for the second time, the MediaPlayer stops to play.
when I've added some breakpoints, I've noticed that after the first read, the MediaPlayer.state is paused, but it still plays.
I have some kind of a media player in my app, so I have some listBoxes that are filters, I want to read to selected filer (artist, album, etc.). so basically using the reader happens when selected item is changed. I'm using both MediaPlayer and MediaElement because if i won't pause the mediaPlayer, it will stop, and I will lose the position of the playing song. and because I want the reader to play gapless I'm using a mediaElement.
I'm lost...
Try looking at this (Music + Videos Hub Sample) http://go.microsoft.com/fwlink/?LinkID=203588 which I think you already use (using the media libraries on the phone), but try combining it with this (Silverlight Sound Sample) http://go.microsoft.com/fwlink/?LinkID=207868, which shows how to use XNA to play sounds in parallel.
If you carefully mix & match these 2 examples, you can achieve what you want, I’ve just tried it myself. Simply copied all that’s needed from example 1 into example 2, and it works just fine: the background music plays, and the birds happily chirp without harming one another.
Let me know if you have problems with it.
BTW - over here: http://msdn.microsoft.com/en-us/library/ff431744(v=vs.92).aspx you have many working examples, for many different things. I took both examples above from this link.
Eyal
Related
I have an interactive pdf document that is displayed fullscreen. there's a navigation bar that users can press to jump to different pages.
What I need is some sort of looping screensaver (a collection of photos) that can be enabled by the user pressing a button.
I considered dropping in a video of a slideshow that I made in after effects, until I realised it's not that easy to loop the playback of that video!
How can I loop a video that I have placed onto a page in a pdf? I've read somewhere about swf's looping but I've tried that and there's no loop option when I place the file in acrobat?
Can someone give me some advice as I thought it would be pretty straightforward to loop a video and now it's looking far from easy.
Thanks
If it is just a slide show, meaning changing images at regular intervals, a few things could be done with Acrobat/Reader's on-board means.
In Full Screen, Acrobat allows to cycle through pages every whatever second. A button on those "screensaver" pages would get back to a "real" page. The question is whether that would interfere with the rest of the document.
Another approach would be having a Button field, icon only, read-only, no action, where you would show an image (preferably PDF) as an icon, and have a control loop running (using interval, timeout) loading different icons. This could be implemented with quite little JavaScript.
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
i want to play an audio or video file, and i made this but i do not know how i can check whether media element is playing file or not?
Like using same button for Pause and Play how i can know that media is also playing file or not?
i use below code to play the file
mediaElement1.LoadedBehavior = MediaState.Manual;
mediaElement1.Source = new Uri("C:/test.wma", UriKind.RelativeOrAbsolute);
mediaElement1.Play();
And one more thing i know how to play file in media element by code. I want to to design media element UI. how i can design this for both video and audio files? what properties should enable and what should be disable.
Last I checked you can't unless you are using Silverlight:
http://msdn.microsoft.com/en-us/library/cc189079(v=vs.95).aspx
I have an application using .Net 4 and as far I can remember you cannot verify if it is playing, stopped, paused, etc.
This is what you can do with .Net 4:
http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement(v=vs.100).aspx
Compared with Silverlight:
http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement(v=vs.95).aspx
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.
I'm trying to be able to affect SpeedRatio on a MediaElement whilst having the media play in a continous loop.
This is possible through code behind; I can reset the position of the media once it has ended, but that creates a seam in the playback.
For seamless playback, I use a MediaTimeline, but when I use I media timeline, I can't change the SpeedRatio.
Has anyone got a different approach to looping playback in a mediaElement, or handling SpeedRatio?
UPDATE:
If I stop the timeline, change the timeline's SpeedRatio, I can produce the result I'm looking for. The only remaining problem is getting the timeline to start from the same position that it was stopped at. Pausing the timeline does not allow for the SpeedRatio to be changed.
I still welcome any alternatives.
My MediaUriElement in my open-source project has a "Loop" property that can provide seemless looping. Get it from the source because it's the newest.
The only solution I've found for this is to use XNA to control audio. It's got a lot more responsiveness.