Accessing MediaPlayer in Background Agent in Windows Phone 7 - windows-phone-7

I am trying to capture the current playing track in the Zune music player, in my Background Agent app. Looking at the Unsupported APIs for Background Agents page on MSDN, all of XNA is not supported - which means I can't use XNA's Media.MediaPlayer. Is there any workaround or solution for this?

Nope.
There is currently no way to access anything other than the tracks which you are playing in a BackgroundAudioPlayer agent.

Actually, there is no way to access anything other than THE track (not tracks) that the background audio player is playing. There is no concept of a playlist exposed by the BAP singleton, which apparently is the source for much frustration with this component. You have to resort to IsolatedStorage or some other hack to feed the BAP a playlist.

Related

Recording Audio Stream in Background in Windows phone 7/8

I m developing an app which can record audio stream.
I want to know that is it possible to record that audio in background, i,e when the application is in deactivated mode?
I have already tried to do that in many different ways,but its not helping out.
Please suggest me some way to do such...
Thank you.
As mentioned in the comments, it's not possible to record in the background.
Your app must be running in the foreground for it to be able to record audio using the microphone. For an overview of all the audio recording options, please refer to this tutorial on the Nokia Developer Wiki.
Also, an app will not run when the phone is locked - it is suspended. So if your app was recording, it would stop when the phone is locked. You can change this behaviour with IdleDetectionMode.Disabled which means your app keeps running even though the phone is locked.
Haven't implemented it before, but classifying it as a VOIP app could be the way to go:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207046(v=vs.105).aspx

WP7 background audio resources are no longer available

I'm using BackgroundAudioPlayer for my Windows Phone 7 music & video application. After I play some music, I play video using MediaPlayerLauncher, then press Back to return to my app. There whenever I use BackgroundAudioPlayer.Instance. I receive error "The background audio resources are no longer available".
Someone on MSDN suggests using try/catch, but this is not a good idea, and can slow down the app.
Other suggests call BackgroundAudioPlayer.Instance.Close() before launch MediaPlayer. However, when I play music, the agent load .dll again, which takes very much time.
How to fix this ?
If you play a video after your audio the OS will definitely "terminate" your Background Audio Player. From your question it seems this is reproducible 100% of the time which would confirm this. Your only option is to restart the background audio player again after you have called BackgroundAudioPlayer.Instance.Close(), and then played your video. Which as you said will require reloading your player DLL when you start the BAP.
Update following up from comments
If you aren't implementing a streaming audio agent but only an AudioPlayer agent there isn't a process for you to kill anyway. The OS spins up a process as and when it needs to get you to process an action (e.g.: user action, track ended, shutdown).
BackgroundAudioPlayer.Instance.Close() just makes sure that the OS releases those resources cleanly in a scenario such as the OP has.
To restart background audio, just call BackgroundAudioPlayer.Instance.Play() again.

Record audio in background

I'm wondering if anyone has any idea that capture audio from the device's microphone on the new Windows Phone 7 in background (Silverlight, not XNA)
or any code to do it?
Even in a Silverlight application, the Microphone is accessed via libraries in the Microsoft.Xna.* namespaces.
The use of such namespaces is not supported in a Background Task. See http://msdn.microsoft.com/en-us/library/hh202962(v=vs.92)
This is not possible and would break the security principle of not allowing apps to do something that the user isn't aware of.

windows phone background player share

I'm developing a windows phone app with a background player based on the windows phone 7.1 project template(so i have 2 projects). My question is how i dynamically set the list of tracks for the background player to play? I tried static fields but didn't work and my guess is that i have to define a resource in the app.xaml but how it is done exactly? I need to share a List and an integer.
Thanks for the help!
The audio agent won't be able to read any resources in the App object (app.xaml).
As far as I can see the only way to communicate between your app and the background audio is via the BackgroundAudioPlayer.Instance object, the AudioTrack (see especially the Tag property) and using files stored in Isolated Storage.
This is described on MSDN here.
Also check out the Background Audio player in the MSDN code samples.

Mute other applications' sound when my application is playing a sound

I would like to mute other applications sounds when my application is playing a sound. I know that this is possible in Windows 7 because it allows sound control on a per-application basis.
The specific scenario is my app needs to have its sound play exclusively; if other applications (eg Winamp, Media Player Classic etc) are playing a sound, they should be muted for the duration of the sound played by my application.
I would like to know how it can be done using Delphi? Which library/system call?
I doubt this is easily achieved.
What if the other apps took the same view? Suppose another app decided that it wanted its sound to play and mute all other apps. Which app would win?
On Vista & above you can do this by using CoreAudio/WASAPI & an exclusive mode stream.
Mumble is doing this, you can look at source code.

Resources