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.
Related
So I've had a look around and I cant seem to find an answer anywhere so here goes. Is it possible with the MS Band SDK to run a function within my app when the user taps a button?
Currently (at the time of writing) there is no way for the user to directly interact with a tile-app and thus pass a response to the application installed on the phone*
Your options are (as I see it):
To use the sensors to define 'gestures'**
Guide the user to use Cortana to provide speech commands ***
*This might change, but due to the very little storage capacity on the band if this was added I would assume only very basic interaction such as yes/no/cancel dialogos etc. and simpler responses using the keyboard when/if it becomes available for third party tiles.
**There is currently a bug with background work so you might have to prevent the lock screen from locking while receiving and interpreting sensor data on the phone which will impact the battery on the phone. This is expected to be fixed soon.
*** Speech commands are well supported on Windows Phone but I'm unsure how well supported they are on iOS and Android
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.
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).
we are creating a windows Phone 7.5 application, this application is developed for specific purpose for company field employes, phones will contain the data sim. No communication allowed like making a phone call, sending sms or chekcing and repling email etc. This application will receive the Push Notifications from our application in the head office.
Is there any way that we can keep this application always on top, regardless what button is pressed by the user we want this application to always stay on top so what ever the notification it receive it will always disply it to the user for futher action.
Thanks
This requirement is not really feasible for a couple of reasons. First, what you are describing actually breaks most of the concepts that a certified app is required to follow. A subset of certification details can be found here: http://msdn.microsoft.com/en-us/library/hh184840(v=vs.92).aspx
Secondly, even if you planned to override the back button (possible) there really is no way to override the Windows, search or camera button at the OS level.
Best of luck!
Short answer: you can't. Application switching is part of the OS, and you don't have control over it.
Best workaround is to pin the app to start and allow it to do background processing with updates to the live tile.
If it's an absolute requirement, you'll have to jailbreak the phone and install your own OS on it.
I have an old landline phone and am looking for a way to make it ring when it's connected to the modem of my home server. I want to use it as a notification when a build is broken and stuff like that. Like most modems, the one in my server has two line jacks, one for data and one for a phone. Since I can only programmatically manipulate the data line, I'm guessing I'm going to have to plug the phone into the data line and simulate a connection somehow but that's where I'm drawing a blank.
I've read up on phone phreaking and telephone ringing circuits but I'm not real sure how that would translate to code, if at all. I can't imagine I'm the only one to think about this so I'm guessing it's either not possible or too hard to be practical. Any help is great. Thanks.
Generating ringing power is beyond the capabilities of modems. The only way you could ring the phone is to actually have two real switch lines, connect the phone to one, modem to the other and actually call the phone.
I once put my multimeter across the phone line and then made it ring. This was probably 20+ years ago, but I still remember: the line went up to 90+ volts (AC). So I guess the phone expects to see a 90v signal for it to ring. It seems highly unlikely that the modem would be able to emit that signal, and also unlikely that the modem could provide the necessary current (as Martin said).
I have one idea but it will depend on your phone line provider. I don't know if it still works, but years ago in Australia you could dial a certain short number and then hang up, and the exchange would call you back right away. Very useful for the phone tech to test the line I guess. So if you can find out if your provider has a number that does that, all you have to do is command the modem to dial that number and then hang up. Then you can keep monitoring the line and after it rings a few times, tell the modem to pick up and hang up again to make it stop ringing.
Here's an idea that doesn't use the modem at all. You could connect to a VOIP service (there must be APIs for some of them) and just dial your phone number through that. You'd never answer so it would never cost anything.
Someone asked similar question in 2004 and get answered in 2010. for your reference: http://www.overclockers.com/forums/archive/index.php/t-283831.html
Do you have to use a land line phone?
If the server is connected to the internet you could ring your mobile (or send an sms message) whenever a build fails.
Otherwise you could hook up speakers to the server and play a ring tone through the speakers whenever you need to.