This question is related to another question i have asked:
MediaPlayerLauncher on WP7 - how to resume previously playing media?
Quick overview: Users can view movietrailers in my WP7-app, using MediaPlayerLauncher.
I am able to resume "normal music" when my trailer is done, like you can see on my other asked question. However, neither radio nor spotify-music resumes. When navigating to the spotify application after a movietrailer is finished, the song that was playing has the pause-icon active (e.g it looks like it's playing), but the timer has stopped. Tapping the pause-icon has no effect (it doesnt switch to the play-icon at all). To start listening again i have to select a different song.
Do i have to resume radio/spotify-music after a trailer is done, or the user quits it, to get my app accepted in the Windows Phone Marketplace?
Independent of what the answer of #1 is, id like to know how to achieve this, if its possible
Section 6.5 (6.5.1 and 6.5.3) in the Additional Certification Guidelines gives the answers: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh184838(v=vs.92).
Normally you have to ask explicitly to play media if music is already playing (6.5.1). However, there is an exception which applies to you for 'non-interactive full motion video' (6.5.3), with extra the requirement that yes, you do have to resume the music afterwards.
Here are a couple of links that might help with resuming the original music after the video plays: http://www.governor.co.uk/news-plus-views/2011/2/16/resuming-background-music-in-wp7-applications and http://gdwp7dev.wordpress.com/2010/10/19/resume-the-users-music-after-mediaplay/
Related
Researched a lot for Solution for recording voice in Background (When another app is running/ when phone is locked, etc).
Searched whole MSDN, stackoverflow for any solution regarding this, Still didn't find it.
Also checked the Api references, they say MediaCapture wont work in background.
But I found two apps, which can record in background. As reverse engineering is not possible with encrypted app, I can't check how did they achieve it.
http://www.windowsphone.com/en-us/store/app/pocket-recorder/eda4e045-733f-e011-854c-00237de2db9e
http://www.windowsphone.com/en-in/store/app/voice-recorder-8-1/511c6375-8bf3-4d19-8248-1650a60ea1ae
I checked whether they use Voip Capabilities, but it is not listed. So there is some other work around, But don't know how!. These apps are paid, so I wish to help community with free solution.
I don't believe you can do this with background tasks. This is because if your app has a lock on the microphone, you won't be able to perform certain functions with your phone (i.e. phone calls)
Yes, Voice Recorder can record voice at the background by stopping every audio files and listening from the phone mic. Even if you switch the screen off, or the screen shut off, the under dog software will still be very active and recording the least sounds it hears and very powerfully clear. Now, I am very surprised to find a software that broke the feats of windows phone, although the software can not allow you to copy the recorded file to sd card or to the phone memory unless a paid version. This is good all the same.
I have a mp3 file. I have a background sound file like rain sound or some fire sound. I want to play these two files parallel in the app as well as in background. So that it looks like a single music is playing a story with a background. Please provide any guidance to achieve this.
AFAIK there are four ways to play audio in WP: BackgroundAudioPlayer, MediaElement, SoundEffect, Microsoft Media Foundation. As for your question:
BackgroundAudioPlayer - it won't work, as there is only one Instance of BAP on the phone. So to play a different file, you have to change Track's Source, so it won't handle two at the same time.
MediaElement - it's also a bad idea (it won't also run with BAP simultanously), because as MSDN says:
When a MediaElement control plays audio or video content, any background sounds or media already playing are halted. The app launches the playback experience when the user taps the control. Only one MediaElement control can operate at a time.
you can try to play many sounds using SoundEffect (thougt as Documentation says it can be only a wave file), I won't post code here, because there are already many examples: one, two, three
as for Microsoft Media Foundation: Walkthrough, Programming Guide, Supported file formats
around a week ago, I submitted an online Background Radio Streaming app for the Windows Phone store. The app was quite good (as I used the Emulator to test it, it was good on all the possible sectors) but when I submitted it for certification, it failed.
According the the error log, if someone is already playing a Music from Music + Video hub and then tries to open this app, both of the apps Crash and stop unexpectedly.
So far I understood, it is because the Music of Music + Video hub is also Background Music and for playing 2 Background Musics at the same time, the apps are Crashing. It can be some other reason but the described one seemed more logical to me.
So, is there anyone who can tell me how to change the state of the app of Music + Video hub? I want to pause or stop the app of Music + Video hub for the time being so that both of the states of the app are not same. In that way, the apps won't clash with each other in the background.
Can anyone help me in this regard?
Use gameHasControl to check for other BAP using music:
bool gameHasControl = Microsoft.Xna.Framework.Media.MediaPlayer.GameHasControl;
if (!gameHasControl)
{
MessageBox.Show("stopping other player"); // normally you should ask if to do that
BackgroundAudioPlayer.Instance.Stop();
}
Once it is Stopped, when you start your BAP, then old instance invokes Shutdown(), and your BAP will be new Instance, which you can normally use. The same is when your BAP is in memory and you start to play from Music+Video Hub.
Only watch out, because when you use XNA, you sometimes need to do:
FrameworkDispatcher.Update();
Otherwise your App will sometimes crash. Good luck.
EDIT - after comment
To make it work you need to add a reference to Microsoft.Phone.BackgroundAudio or use like this:
Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer.Instance.Stop();
BackgroundAudioPlayer is a Singleton which you are allowed to use - in this case - Stop it playing (of course give the choice to the User).
I am coding a WP7 & WP8 sports tracking app that gives the user feedback through voice coaching. If a user is playing music, it needs to be paused, the voice coach needs to speak and finally the music must be resumed again. For the standard music player, i based my coding on the information given on this website, and it works for the standard music player, but not for Spotify.
I've been looking into it and the mediaplayer seems to lose track of Spotify when i pause their music, and Spotify seems to crash. There is no music in the MediaPlayer.Queue when Spotify is playing so i can't save and restore that. It's also not possible to simply try a MediaPlayer.Resume(); after pausing Spotify because the music player does not know what to play anymore due to the empty playlist.
Is it possible to create a windows phone app that is compitable with Spotify?
Thanks.
This isn't possible as 3rd party media applications such as Spotify don't use the MediaPlayer and so MediaPlayer.Resume() won't work for them.
You could request Microsoft to implement this in a future version the OS via the uservoice site.
I have developed a music player app for Windows Phone 7.5 and Windows Phone 8. Now I want to listen to the music with various bluetooth devices. I can connect it to my phone and listen to music, so that's working just fine. But it acts weird in certain scenarios. If the music is paused it will resume on the speakers if I disconnect the bluetooth. I can see in my log that it receives a user action to UserAction.SEEK to the position it was when I turned off bluetooth. At this point, the player.Position variable has somehow gotten to be 0, so it goes to 0 and back to where I was. And I don't do anything that would cause that action.
What I am asking: Is there a way to take over control or to get any control in the AudioPlaybackAgent that I use of what happens when I do something with my bluetooth devices. Is there any event that occurs, or is all this handled by the OS? If so, why does my application behave differently than the stock app? Also, why am I receiving a UserAction.SEEK when I turn of my bluetooth device?
If my question is unclear, please don`t hesitate to ask!
This is a known issue with the platform, but is fixed in WP8 GDR2. You can workaround the issue by detecting an OnUserAction sequence of Pause Seek Play. Once detected, you can pause on the next call to OnPlayerStateChanged. A few things to be aware of:
Consecutive calls to OnUserAction aren't guaranteed to be called on the same instance of AudioPlayer, so any state should be stored in static state.
The track will play from the speaker for a brief moment, so you might want to set the volume to 0 (after making note of it's previous value, of course)
I've posted a Gist to GitHub with a full implementation. Example usage and a more detailed rundown of the problem is available on my blog.