Windows Phone 8 中的 Cordova 媒体插件和本地文件

Cordova media plugin and local files in Windows Phone 8

我想将 cordova 应用程序移植到 Windows Phone 8 平台。但是声音问题来了。

有字符串 new Media('/android_asset/sounds/bell.wav').

当我将参数更改为'sounds/bell.wav'时,错误代码为1。 如果我输入 'x-wmapp0:www/sounds/bell.wav' 或 'file:///www/sounds/bell.wav' 没有错误,但没有播放声音。

来自 Internet 的 URL(文件和流)播放良好。

请帮我想办法在 wp8 上从应用程序播放本地文件。

var mypath = location.pathname;

var idx = mypath.lastIndexOf('/');

var backgroundMusicFilePath = mypath.substring(0, idx + 1) + "audio/BackgroundMusic.mp3";

app.backgroundMusic = new Media(backgroundMusicFilePath);

我项目的本地 mp3 存储在 www\audio 文件夹下。获取本地文件很棘手,因为它与 iOS、Android 和 WP8.

不同

我必须在 windows 10/windows phone universal

上执行以下操作

//index.js
var url = document.getElementById("idAHidden").href
console.log(url)
<!--index.html -->
<a href="" style="visibility:hidden" id="idAHidden"></a>