首先是看了github上的这个https://github.com/angular/angular.js/issues/1352,知道了语音播放不了了,下面是正确的播放代码
首先添加过滤器
app.filter("trustUrl", ['$sce', function ($sce) {
return function (recordingUrl) {
return $sce.trustAsResourceUrl(recordingUrl);
};
}]);
页面标签
<div class="problem-voice" ng-click="playQAudio()">
<audio id="qAudio">
<source ng-src="{{touser.content | trustUrl}}">
</audio>
<i class="fa fa-volume-up" aria-hidden="true"></i>
</div>
点击播放事件
//播放语音相关
$scope.playQAudio = function () {
var audio = document.getElementById("qAudio");
audio.load();
audio.play();
};