我是Cordova / Ionic的新手,我已经设法使用包含ng-cordova的NativeAudio插件在我的应用程序中重现mp3文件。 我安装了CordovaSocial插件,但我无法弄清楚如何将音频文件发送到whatsapp。 mp3在www / audio / bass.mp3
中使用这些行我可以重现mpfile
$scope.play = function(audioFile) {
$cordovaNativeAudio.preloadSimple(audioFile, 'audio/' + audioFile + '.mp3');
$cordovaNativeAudio.play(audioFile);
}
这是我的代码
在html文件中类似
<div class="buttons" ng-click="shareViaWhatsApp(null,null,'audio/bass.mp3')">
<button class="button">Whatsapp</button>
</div>
并在js文件中
$scope.shareViaWhatsApp = function(message, image, link) {
$cordovaSocialSharing.canShareVia("whatsapp", message, image, link).then(function(result) {
$cordovaSocialSharing.shareViaWhatsApp(message, image, link);
//$cordovaSocialSharing.shareViaWhatsApp('test message', null, null); //this works
}, function(error) {
alert("Cannot share on WhatsApp " + error);
});
尝试通过whatsapp发送mp3文件时获取URL_NOT_SUPPORTED