Media API

From WebOS Internals
Revision as of 16:51, 2 March 2010 by Bsiegel (talk | contribs) (Initial commit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here is where you may find research on undocumented Media API calls. The hope is to enable earphone playback, microphone recording, and perhaps even raw video access.

Playback through earpiece

This code will cause further audio playback to be directed to the earpiece: <source lang="javascript"> var request = new Mojo.Service.Request('palm://com.palm.audio/media', {

   method: 'enableScenario',
   parameters: { "scenario":"media_front_speaker" },
   onSuccess: function() {
       var request2 = new Mojo.Service.Request('palm://com.palm.audio/media', {
           method: 'setCurrentScenario',
           parameters: { "scenario":"media_front_speaker" },
           onSuccess: this.playSomeSoundThroughTheEarpiece(),
           onFailure: this.doSomethingIfTheMojoCallFails()
       });
   }.bind(this),
   onFailure: this.doSomethingIfTheMojoCallFails()

}); </source>


This code will revert audio playback back to the speaker: <source lang="javascript"> var request = new Mojo.Service.Request('palm://com.palm.audio/media', {

   method: 'disableScenario',
   parameters: { "scenario":"media_front_speaker" },
   onSuccess: this.playSomeSoundThroughTheBackSpeaker(),
   onFailure: this.doSomethingIfTheMojoCallFails()

}); </source>


If you enable the earpiece at some point during your app's run, you MUST remember to reset the playback to use the speaker before your app exits. Always put things back the way you found them!