언어 설정

Menu
Sites
Language
Music application under lockscreen

Hi,

I'm developing a music application and I would like to keep the music playing even when the lockscreen goes on. Is there a web API to do this?

BR,

Antti

Edited by: Brock Boland on 17 3월, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

4 댓글
Raghavendra Reddy Shiva
you can try as below, // This function call in the init function of the application loadSoundFile('Samplefile.mp3'); var context = new window.webkitAudioContext(); var source = null; var audioBuffer = null; function stopSound() { console.log('stopSound called'); if (source) { source.noteOff(0); } } function playSound() { if (audioBuffer) { console.log('Creating source buffer'); source = context.createBufferSource(); source.buffer = audioBuffer; //source.loop = false; console.log('Connecting source to destination'); source.connect(context.destination); source.noteOn(0); console.log('Playback started'); } else{ console.log('Audio file not decoded yet'); } } function decodeAudioFile(arrayBuffer) { console.log('Decoding array buffer..'); context.decodeAudioData(arrayBuffer, function(buffer) { audioBuffer= buffer; console.log('Decoded data ready'); }, function(e) { console.log('Error decoding file', e); }); } function loadSoundFile(url) { console.log('loadSoundFile'); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { decodeAudioFile(this.response); // this.response is an ArrayBuffer. }; xhr.send(); } The playback continues even when the application goes in background. But there is a delay in starting the file playback. It seems the webkit decoding is taking longer time. In the above case, when launch the app, wait till you see the "Decoded data ready" in the logging (decoding happens in background, when app is launched) and then start the playback. Of course, this might not work for multiple file playback, as we cannot decode them all in advance. Below is the JIRA for the delayed playback issue. https://bugs.tizen.org/jira/browse/TWEB-148
Raghavendra Reddy Shiva
This is faster, but this doesn't work when the application goes in background. var Player = function () { this.audio = new Audio(); } Player.prototype.play = function (url) { this.audio.src = url; this.audio.play(); }
Antti Pohjola
The problem is that I'm using HTML5 streaming audio, so this doesn't help me much :(
Kirill Chuvilin
The same discussion. https://developer.tizen.org/forums/web-application-development/web-audio-api-delay-local-files