Hello,
I'm building an HTML5 iOS application using the Intel XDK. I'm using the Cordova Media plugin to play .wav audio files. For some reason, the audio will only play for about a second before quickly fading out. I can't figure out why this is happening.
I have two buttons, one that toggles recording audio and another to toggle playing the recorded audio. Here are the relevant javascript functions.
var audioButtonDisplay = 0;
var audioRecordButtonDisplay = 0;
var audioRecord;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
audioRecord = new Media(audioSrc, function(){}, function(){alert("audioRecord error");});
audioRecord.setVolume(0.9);
}
function togglePlayPause() {
var playPauseButton = $("#playPauseButton");
if(audioButtonDisplay === 0) {
audioButtonDisplay = 1;
playPauseButton.removeClass("playButton");
playPauseButton.addClass("pauseButton");
playPauseButton.html("II");
audioRecord.seekTo(0);
audioRecord.play();
}
else if(audioButtonDisplay === 1) {
audioButtonDisplay = 0;
playPauseButton.removeClass("pauseButton");
playPauseButton.addClass("playButton");
playPauseButton.html("►");
audioRecord.pause();
}
}
function toggleRecording() {
var audioRecordButton = $("#audioRecordButton");
if(audioRecordButtonDisplay === 0) {
audioRecordButtonDisplay = 1;
audioRecordButton.removeClass("purple");
audioRecordButton.addClass("red");
audioRecordButton.html("Stop Recording");
audioRecord.startRecord();
}
else if(audioRecordButtonDisplay === 1) {
audioRecordButtonDisplay = 0;
audioRecordButton.removeClass("red");
audioRecordButton.addClass("purple");
audioRecordButton.html("Start Recording");
audioRecord.stopRecord();
}
}Please help me get the audio to play the full length. Thanks.