A simple background service which detects any playback on the global audiomix and then opens the BluetoothSco channel so the audio is played on your mono Bluetooth device (hands free profile).
Idea
Enable the dynamic playback of any media sound on the Bluetooth device. Especially for the direction guide of your navigation software. The Bluetooth channel should be opened when a playback is started and closed after the playback is finished.
Comparison to similar apps:
All other apps I've seen are not dynamic or (I suppose) use the isMusicActive() function which in fact isn't reliable. Therefore I use the Visualizer API to grab anonymized info from the global audiomix and can for sure determine if audio is played. The visualizer API function I use is only available since API Level 19 (Kitkat - Android 4.4). For API Levels below I use the isMusicActive() function as well.
State based redirection
The service is only startable if the bluetooth adapter is turned on, everything else wouldn't make sense would it? The redirection only starts if a bluetooth device is connected to the hands free bluetooth profile. If the hands free connection isn't available anymore the redirection stops.
Static redirection
If you choose this option the audio redirection will start as soon as you start the service and only stops with the service. No audio information is analyzed.
If you choose the reconnect after call option the service restarts itself after a voice call is terminated (the telephone app has priority over the sco channel). The service also restarts if you end the "call" for media redirection. This option is only available in combination with static redirection.
Intent to start/stop the service
It's really really simple! Send of the following intents
•net.philipp_koch.dynamicmediabtrouter.ON
•net.philipp_koch.dynamicmediabtrouter.OFF
Requirements:
•An Android device with the minimum API Level 11 (Honeycomb - Android 3.0)
- API Level 18 (Jelly Bean - Android 4.3) for a raw bluetooth stream. Lower version may require you to accept the "call"
- API Level 19 (Kitkit - Android 4.4) for audio recognition via the visualizer API.
•A bluetooth device which supports the hands free profile (usually headsets or car speakerphones)
•No task managers! They're crap and nothing else! They kill the background service so don't complain!
Working as designed (dynamic mode)
If you end the "call" the redirection doesn't stop and audio is routed to nowhere. Because the app was intended for navigation apps this is a useful design:
If redirection starts and you are already aware of the information presented you could end the "call" as soon it starts. After the information is played the service will close the channel as usual and open it again as soon as audio is detected.
If you use the app to redirect music for an ongoing time and you end the "call" accidentally you have to pause the music for at least a few seconds. The service will stop the redirection and start it again as you press play.
You experience a bad audio quality
I can't fix that. The hands free profile isn't intended for high quality. You have to use A2DP instead!
What’s left to do?
• stop Service from notification
Oxirgi yangilanish
27-yan, 2018