我是Android编程的新手。, 现在,我正试着用phonegap播放声音。, 这是我的完整代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1">
<link rel="stylesheet" href="script/jquery.mobile-1.2.0.min.css"/>
<link rel="stylesheet" href="script/blues.min.css"/>
<link rel="stylesheet" href="script/style.css"/>
<script src="cordova-2.3.0.js"></script>
<script src="script/jquery-1.8.0.min.js"></script>
<script src="script/jquery.mobile-1.2.0.min.js"></script>
<script src="script/scripts.js"></script>
<script type="text/javascript">
var sound;
function playAudio(src) {
sound = new Media('/android_asset/www/sounds/' + src, onSuccess, onError);
sound.play();
}
function onSuccess() {
console.log("playAudio():Audio Success");
}
function onError(e) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<a href="hira_menu.html" data-icon="grid" data-iconpos="notext" data-transition="fade">Upper Menu</a>
<a href="search.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="pop">Search</a>
</div>
<div data-role="content">
<div class="ui-grid-d" align="center">
<div class="ui-block-a">
<a href="#a" data-rel="popup" data-position-to="window" data-position="center"
data-inline="true"><img
data-role="button" src="images/hiragana/base/a.png"></a>
</div>
</div>
</div>
<div data-role="popup" id="a" class="photopopup" data-overlay-theme="a" data-corners="false"
data-tolerance="30,15">
<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a><img src="images/hiragana/a.gif">
<div align="center">
<a href="#" onClick="playAudio('aaa.mp3')"><img data-role="button" data-iconpos="notext" src="images/sound.png"/></a>
</div>
</div>
</div>
</body>
</html>
问题是我遇到了这个错误:
CordovaLog Uncaught ReferenceError : playAudio is not defined
Web Console Uncaught ReferenceError : playAudio is not defined at file:///android_asset/www/hira_menu.html : 1
注意:文件hira_menu.html是此文件之前的文件。 我在这个论坛上搜索了解决方案,但它仍然没有用。 任何人都知道解决方案,请...