Home > Android, PhoneGap > Phonegap Media API

Phonegap Media API

I have done several research on the internet for phone gap media API and finally found.

Here is the Sample Code
Properties/WPAppManifest.xml

<Capabilities>
<Capability Name=”ID_CAP_MEDIALIB” />
<Capability Name=”ID_CAP_MICROPHONE” />
<Capability Name=”ID_HW_FRONTCAMERA” />
<Capability Name=”ID_CAP_ISV_CAMERA” />
<Capability Name=”ID_CAP_CAMERA” />
</Capabilities>

index.html

<html>
<head>
<title>Media Example</title>
<script type=”text/javascript” charset=”utf-8″
src=”cordova-1.9.0.js”></script>
<script type=”text/javascript” charset=”utf-8″>
function playAudio(url) {
// Play the audio file at url
var my_media = new Media(url,
// success callback
function() {
console.log(“playAudio():Audio Success”);
},
// error callback
function(err) {
console.log(“playAudio():Audio Error: “+err);
});

// Play audio
my_media.play();
}
</script>
</head>
<body>
<a href=”#”
onclick=”playAudio(‘http://www.wav-sounds.com/funny/911.wav’);“>Play Audio
#01</a><br/><br/>
<a href=”#”
onclick=”playAudio(‘http://www.wav-sounds.com/funny/crash.wav’);“>Play
Audio #02</a>
</body>
</html>

If i click “Play Audio #01”, the wave file plays, next if I try playing “Play Audio #02” it goes in the error section with no details about the error. This happens only for Windows Phone, works for Android.

Categories: Android, PhoneGap Tags: , , , ,
  1. April 20, 2014 at 1:41 am

    I am in fact grateful to the owner of this web site who has
    shared this fantastic article at at this time.

  1. No trackbacks yet.

Leave a comment