我正在使用离子框架来创建移动应用程序并在我的浏览器上进行测试。
ng-click =“play('music / work.mp3')”//按钮
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script><!-- ionic/angularjs js -->
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
.controller('ChatsCtrl',function($cordovaMedia,$ionicLoading,$ionicPopup,$scope,$ionicTabsDelegate,$ionicScrollDelegate,repository,$ionicModal) {
$scope.play = function(src){
console.log('trytrytryyyyyyyyy');
var media = new Media(src, null, null, mediaStatusCallback);
$cordovaMedia.play(media);
}
var mediaStatusCallback = function(status) {
if(status == 1) {
$ionicLoading.show({template: 'Loading...'});
} else {
$ionicLoading.hide();
}
}
我使用了以下代码。我收到这个错误。我不知道我做错了什么。我按照这条指示https://blog.nraboy.com/2014/11/playing-audio-android-ios-ionicframework-app/