問題描述
在 windows phone 7 應用程序中流式傳輸音頻 (Streaming audio in windows phone 7 app)
If I do this in Javascript I can play the music streak behind the source url. No problem.
var music = new Audio();
var source = http://*HOST*.grooveshark.com/stream.php?streamKey=*STREAMKEY*;
music.src = source;
music.play();
Even better I can have a web control in my WP7 app that does this, and magically I have music playing in the app. However, I want to have audio int he background as well. So I can't just stream audio in a web browser control.
I need to take the above kind of audio source, but use it in a native Windows Phone app. There seems to be lots of ways, MediaElement, BackgroundAudioPlayer, etc., etc.... but none of them seem to work the the above url. I can pass them a link to an mp3 on a server somewhere and everything goes fine. But I can't seem to stream audio on a windows phone via a url like this.
‑‑‑‑‑
參考解法
方法 1:
Try JavaScript way with Phonegap Media API for Windows Phone
Cordova Media API
and do it look like:
my_media = new Media("test.mp3", onSuccess, onError);
function onSuccess() {
console.log("playAudio():Audio Success");
}
// onError Callback
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
Hope this help :)
(by fefwfefefwfwe、neung)