In my manifest file I've add the audio-channel-content in permissions:
"permissions": {
"audio-channel-content":{"description":"Use the audio channel for the music player"}
}
In my index.html I've got an audio tag like:
<audio mozaudiochannel="content" preload="none" src="http://my-stream-url"></audio>
I can play my audio stream during 2mn:
The first one when the phone is unlock.
After 1mn my phone auto-lock the screen and it continue playing for another minute.
Does it possible to play this audio stream more than 1mn after the lock?
Thanks in advance.
The code and permission block you have are correct and I can confirm it is working in Firefox OS 1.1. You can also do the whole thing in Javascript:
audio = new Audio();
audio.preload = 'none';
audio.mozAudioChannelType = 'content';
It's because the wifi is closed after screen shutdown (auto-lock)?
Are you using the dev version of gaia? Wifi is set to always connect in product version.
Related
I want to play a sound at start of the GWT client app.
I used the following code
import com.google.gwt.media.client.Audio;
Audio mistakeAudio;
mistakeAudio=Audio.createIfSupported();
if (mistakeAudio!=null) {
mistakeAudio.setSrc("waves/Gong.wav");
mistakeAudio.load();
mistakeAudio.setLoop(true);
mistakeAudio.play();
}
I tested various variations, but finally the sound only plays, if before the command mistakeAudio.play() at least one mouse click happened on the client window. Not even
doing anything..
Is there a workaround - starting really only programmatically?
You can use HTML5 instead:
<audio id="gong" autoplay>
<source src="waves/Gong.wav" type="audio/wav">
Your browser does not support the audio element.
</audio>
or use javascript for the autoplay:
<script>
var audio = document.getElementById("gong");
audio.autoplay = true;
audio.load();
</script>
which you could also code in GWT with JsInterop and Elemental2:
HTMLAudioElement audio = (HTMLAudioElement) Document.getElementById("gong");
audio.autoplay = true;
audio.load();
In a Samsung Smart TV App up to 2014 (not Tizen) I have tried two ways to play a short (about a second) audio file and tested it in the 2014 emulator 5.1:
index.html:
<!-- HTML5 audio tag -->
<audio id="audio" src="http://luniks.net/other/0-99A-Z/1.ogg"></audio>
<!-- Player plugin -->
<object id="pluginPlayer" classid="clsid:SAMSUNG-INFOLINK-PLAYER"></object>
Main.js:
Main.keyDown = function() {
var keyCode = event.keyCode;
// arrow left on remote control, just for testing
if (keyCode == 4) {
// HTML5 audio tag
document.getElementById("audio").play();
}
// arrow right on remote control, just for testing
if (keyCode == 5) {
// Player plugin
var playerObj = document.getElementById('pluginPlayer');
playerObj.Play("http://luniks.net/other/0-99A-Z/1.ogg");
}
};
Each way, the audio file is played only once during the app's lifecycle and only plays again when restarting the app.
I am not sure if the sound is muted or if audio doesn't play at all after it played once.
The same with a <video> tag works fine, the video can be repeatedly played without problems.
When a <video> tag is present (defined after the <audio> tag), the <audio> tag does nothing.
When playing audio with the Player plugin while the video is playing, the video continues to play but is muted.
My final goal is to play a series of short audio files while a video that possibly has (low volume) sound is playing. From my experience so far, I can forget about that. Am I right?
Just add loop="true" in the audio tag and test. It works fine for me.
I'm trying to play Apple HLS stream on samsung TV:
https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
Model code:UE40F5500
Version : 5.2481
Any idea why?
Playlist contains audio-only track. Usually SmartTV's not support this and refuse to play such playlist or throw error during track switching.
If you look at playlist:
$curl https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
You will see last track without video:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=232370,CODECS="mp4a.40.2, avc1.4d4015"
gear1/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=649879,CODECS="mp4a.40.2, avc1.4d401e"
gear2/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=991714,CODECS="mp4a.40.2, avc1.4d401e"
gear3/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1927833,CODECS="mp4a.40.2, avc1.4d401f"
gear4/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=41457,CODECS="mp4a.40.2"
gear0/prog_index.m3u8
Such track is required by Apple to allow playback of audio over mobile internet, so you can't use playlists from iOS on SmartTV.
I receive over network PCM audio data stream and this part works fine so I am ending up with
DataReader incomming = args.GetDataReader();
byte[] RcvBuffer = new byte[incomming.UnconsumedBufferLength];
incomming.ReadBytes(RcvBuffer);
I have all audio data in buffer.
How I can play this through telephone Speaker ? Can you point me in some direction ?
Thanks
There're many ways to do that.
You can prepend the WAVE header to your data, and use MediaElement for playback, see the documentation for SetSource method.
If however by “telephone speaker” you mean the earphone, then it is only possible if you are creating a VoIP app.
It took a while but I sorted it, maybe someone else will need help in the future.
First Problem - since I just started app development for Windows Phone I have chosen Blank App (Windows Phone) instead Blank App (Windows Phone Silverlight) and I did not have access to many features that are available in Silverlight projects, so my suggestions for beginners: understand what each project is for.
Like Soonts said there are many ways to do this, this is one that I used.
I simplified this code and retyped this so there can be some typos.
using Microsoft.Xna.Framework.Audio;
using System.IO;
1) Create Stream to load your incoming data:
MemoryStream stream = new MemoryStream();
2) Load data from buffer to stream:
stream.Write(RcvBuffer, 0, RcvBuffer.Length);
3) I am using SoundEfect to play this through Loud-Speaker. Sample rate that I use is 8 kHz
SoundEffect sound;
sound = new SoundEffect(stream.toArray(), 8000, AudioChannels.Mono)
sound.Play();
Currently my audio won't play on safari and on mobile devices.
It works fine on a normal pc on FireFox, Chrome and IE
var manifest = [
{ id: "correct", src: 'assets/correct.mp3|assets/correct.ogg' },
{ id: "wrong", src: 'assets/wrong.mp3|assets/wrong.ogg' }
];
var queue = new createjs.LoadQueue();
queue.installPlugin(createjs.Sound);
queue.loadManifest(manifest, true);
And I'm calling the play function like this;
createjs.Sound.play("correct");
This function is written inside a function that's called when a user presses a div.
That code looks like it should work. Web Audio is initially muted on iOS devices, but when play is called inside of a user event it unmutes.
There are a couple of possibilities (without seeing the rest of the code):
You are working on iPad 1, which does not support web audio and has html audio disabled by default due to severe limitations.
You are not waiting for the audio to finish loading before calling play:
queue.addEventListener("complete", loadComplete);
The audio file path is incorrect and therefore the load is failing, which you can detect by listening for an error event.
You are using a non-default encoding for the mp3 files that is not supported by Safari. Generally that would break in other browsers as well though.
Safari requires quicktime for html audio to play, so that could be a problem.
Using createjs.Sound.registerPlugins, SoundJS is being set to use an unsupported on mobile plugin, such as FlashPlugin. You can check your current plugin with:
createjs.Sound.activePlugin.toString();
You may find the Mobile Safe Tutorial useful. Hope that helps.
There is a way to hack it, play an empty mp3 then play the audio.
It must load the empty mp3 within mainfest array firstly:
var manifest = [
...
{ id: "empty", src: 'assets/empty.mp3|assets/empty.ogg' }
];
...
Before playing the sound, play the empty mp3:
createjs.Sound.play("empty");
createjs.Sound.play("correct");