0
votes

I want to port cordova app to Windows Phone 8 platform. But there's come troubles with sound.

There was string new Media('/android_asset/sounds/bell.wav').

When I changing param to 'sounds/bell.wav', error code is 1. If I put 'x-wmapp0:www/sounds/bell.wav' or 'file:///www/sounds/bell.wav' there's no errors but sounds is not playing.

URLs from Internet (files and streams) playing well.

Please help me to find a way to play local files from app on wp8.

2

2 Answers

1
votes
var mypath = location.pathname;

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

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

app.backgroundMusic = new Media(backgroundMusicFilePath);

The local mp3 for my project is stored under the www\audio folder. Getting the local file is tricky because it differs for iOS, Android and WP8.

0
votes

I had to do the below on 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>