|
|
Choice Dialer
Fast, hands-free voice control for Android.
|
|
|
Making a Music App compatible with Choice Dialer
This page is intended for developers of music apps on Android. If you are a
Choice Dialer user who wants his/her favorite app made compatible with Choice Dialer,
please contact the developer of that app and show him/her this page. Thanks.
Choice Dialer can drive just about any music app if the developer spends a little time and shares a little information with me. Users benefit from this sort of cooperative work.
Choice Dialer needs a few simple hooks to work. You probably already have most of this working. Take this as a suggested integration pattern... I am flexible and motivated to make the popular music apps compatible.
Allow me pause your music playback
I'd like to have a quick means (often a broadcast intent)
to immediately pause any playback. I would use this when the user activates my
app and is about to speak a command (when silence is required).
The form Android's stock Voice Dialer app uses to silence the stock music app is:
Intent i;
i = new Intent(yourPackageName + ".musicservicecommand");
i.putExtra("command", "pause");
context.sendBroadcast(i);
One extra suggestion:
If you make your app respond to the broadcast intent used by the stock HTC and Android music apps (package names "com.htc.music" and "com.android.music"), this will cause your app to also pause its music for the people using the stock Voice Dialer app, even if they lack Android 2.2's audio focus calls.
Let me hand in a list of song handles
If the user expresses a wish for music to play ("Play songs by (artist)", "Play the song (title)", "Play songs from (album)" "Play songs from (playlist)", I read the int/long database IDs of the songs that seem to match and then call an AIDL method on your playback service to hand the array of handles in. The desired behavior then, is that any previous playback context be set aside or forgotten, and the playlist provided loaded up for play in the manner your users expect and prefer. If the user wants shuffle play, I shuffle the IDs before sending, so I am not sensitive to needing to understand or use your shuffle mechanisms.
If your existing AIDL provides no such method as the "play this array of DB handles in succession", but the same effect can be managed by a series of calls, that is fine (though I'd strongly prefer not to have to monitor playback -- I want to do this all at one time, in a moment). The means to do this are often through AIDL interface, but anything light and simple is workable, I'd say.
One player which I ALMOST support uses music file paths rather than IDs. I could work with those with some grumbling if this were easier for you. I prefer database IDs.
Let me hand the user off to you
Lastly, knowing a simple, public Activity within your app that I can start after loading up the desired music would be ideal. Whatever activity you have which follows the succession of songs and offers the users the experience and interactivity they value is the right one. Of course it is desireable if it allows them to cursor back and forth through the songs they asked for by voice, but your existing design choices are the appropriate ones, as the user has clearly demonstrated his buy-in to it, yes?
Other hooks
I need functions that loosely match these found in other apps I've worked with, as they allow me to support other voice commands to directly drive your player. Only the first one is super-critical in its precise implementation ... it simply has to say whether the app is presently playing music (that is, has music issuing from the speaker/earphone).
- boolean isPlaying();
- void play();
- void nextSong(); // no matter if it unpauses
- void previousSong(); // no matter if it unpauses
- void pause();
- void resume(); // if it differs from play()
- void stop(); // if you have this at all
- void setShuffle(int or boolean... no biggie);
- void setRepeat(int or boolean... no biggie);
If the above seems workable from your end, please email me as "tone" through this domain name. Thanks.
Choice Dialer is a trademark of Resounding, LLC.
|