Can we get events like start, stop, pause of a video using mediaplayerlauncher and also can we get the length of the video played using the same or we need to go with mediaelement.
Launchers don't allow to communicate with the OS app in any way if no property is defined.
If you want/need control, you need the mediaelement.
Related
noob here.
I am developing an app for windows phone that streams audio from the web. I've put the play function with MediaElement class, and i have no problem with it.
Then, i want to add a feature to get/record the audio that i stream. I've googling and didn't find what i want.
Is there a way to do that?
Regards,
BM
This is the Microphone class link which can be used to capture audi.
Give a try and let me know
Microphone to capture audio
also go nthrough this link
capturing and playing audio
Is it possible to listen to system's volume and music control events (Next/Prev)? I am playing a song from MediaLibrary using MediaPlayer but how to capture Next\Prev button press event? Thanks!
Volume Events
It's not possible to listen for (or subscribe to) the system volume events. You cannot find out the current system volume or know when the volume keys on the phone are pressed.
If your app is playing music using a MediaElement, for example, you simply play the sounds or music blindly not knowing what the system volume is.
Developers have voted to improve this API which will hopefully happen in a future release.
Music Events
If your app is playing music using the BackgroundAudioPlayer, you can subscribe to the PlayStateChanged event. You can detect if music is playing using the MediaPlayer class. Although this is an XNA library, it works in WP7 and WP8.
If the user starts music in your app, it will stop whatever music the system is playing and take over. The opposite is also true. If your app is playing music, and the user goes to another music app, your BackgroundAudioPlayer will receive PlayState.Stopped.
I'm implementing a game for WP7, and I need that a mp3 file plays in background, while I navigate through some screens. How can I do this? Thanks in advance.
Use background Audio agent for this purpose to play , even when user navigate between pages.
Also you can achieve the continuous playback by 2 ways
1. set the repeat option to play continuously
or
2. start play back again upon receiving the stop message, this can be achieved by putting code for starting playback again in Application Background player state handler upon receiving "PlayState.Stopped" message.
Please refer this link "How to: Play Background Audio for Windows Phone" for more details.
Hm.. what about global MediaPLayer instance?
See this link
In my application i am playing an audio file (let it be .mp3) using MediaPlayerLauncher. File is downloaded from network and stored in IsolatedStorage.
I managed to play the audio but it was a bit disapointing to see that there is absolutly no details about the played track.
Is there a way to show picture and/or track name when launched with MediaPlayerLauncher? Or am i forced to use MediaElement?
Unfortunately, if you're just playing an audio stream using the MediaPlayerLauncher there si no way to specifyu additional (meta) data for the launcher to also display.
If you want additional information displayed then you'll need to create the UI yourself and play the track via a MediaElement (or background audio).
what I want to achieve is this:
Play background music from the media library
On a certain trigger, fade out the music, play another mp3 file (of various lengths, seconds up to a minute)
After that piece of audio is played, resume previous music from the library
Now I run into these constraints:
In order to access and play music from the user's library, I need to use the MediaPlayer XNA class.
In order to play an arbitrary mp3 file, I need to use either MediaPlayer or MediaElement, but not SoundEffect or SoundEffectInstance
If I play anything using the MediaElement, MediaPlayer stops. It completely loses the audio queue so I would need to play the remaining music which would be ok BUT
MediaPlayer doesn't support seek so I cannot open the previous song and just go the the position before it got paused
So:
I don't want to use SoundEffect or SoundEffectInstance as the audio would have to be wav files.
I can't use just MediaPlayer because if I played the audio there to interrupt the song I wouldn't be able to seek to its previous position
I can't use the combination of MediaPlayer and MediaElement as MediaPlayer stops the MediaPlayer which again prevents me from resuming previous playback
I can't just use MediaElement because it can't play songs from the library
Do you see anything I missed or is really the only option I have to suck it up and use wav files? (There would be many of these downloaded on the fly and it is just plainly inefficient this way!) Any suggestions?
Thanks!
Unfortunately you've hit a limitation of the platform.
In addition to the alternative you've identified you could play the music streamed from an external source through a MediaElement. By using a timer to keep track of how much has played, when resuming the track start that far through the track by including the start point in your request to the streaming server. This does of course mean you need to provide or find a suitable streaming capability. :(
Neither of these are ideal but for now that's the best we have. The background audio facilites coming in Mango may help but until details are announced we can't say for sure.
can't use just MediaPlayer because if I played the audio there to interrupt the song I wouldn't be able to seek to its previous position
You will get mediastatechanged event using MediaPlayer and inthat event you could check the state of the mediaplayer and Pause the Song and then you could also Resume the song