嘿伙计们,我正在使用媒体 phonegap api 来播放、暂停和停止音频。到目前为止,我设法播放,停止和暂停,但我不知道如何恢复请帮助我
下面是我写到现在的代码
var my_media = null;
var mediaTimer = null;
var pausePos = 0;
var counter=0;
var playing=false;
function playAudio(src) {
// Create Media object from src
my_media = new Media(src, onSuccess, onError);
// Play audio
my_media.play();
// get audio duration
var duration = my_media.getDuration();
// set slider data
if( duration > 0 ){
$('#slider').attr( 'max', Math.round(duration) );
$('#slider').slider('refresh');
}
// Update my_media position every second
if (mediaTimer == null) {
mediaTimer = setInterval(function() {
// get my_media position
my_media.getCurrentPosition(
// success callback
function(position) {
if (position > -1) {
setAudioPosition(position);
}
},
// error callback
function(e) {
console.log("Error getting pos=" + e);
setAudioPosition("Error: " + e);
}
);
}, 1000);
}
}
/* pause audio */
function pauseAudio() {
if (my_media) {
my_media.pause();
}
}
function resumeAudio()
{
}
/* stop audio */
function stopAudio() {
if (my_media) {
my_media.stop();
playing = false;
my_media.release();
}
clearInterval(mediaTimer);
mediaTimer = null;
pausePos = 0;
}
// onSuccess Callback
function onSuccess() {
console.log("playAudio():Audio Success");
}
// onError Callback
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
// Set audio position
function setAudioPosition(position) {
pausePos = position;
position = Math.round(position);
$('#slider').val(position);
$('#slider').slider('refresh');
}
function player(id)
{
//alert(id);
playAudio("/sdcard/MuseumCache/"+id+"/"+id+".mp3");
//alert("end");
}
请帮我写简历功能。他们说 media.play() 播放并继续播放音频文件