silent track
Okay guys, this is probably going to sound stupid but here it goes.
I was listening to an old sng file. In the middle of the file, one track just stops.
The wave form and track are still there, it just falls silent.
I must have done something fairly stupid.
Any suggestions?
Meh !!!
Figured this out - user error.
tions
In one of my earlier posts I discussed some of the issues (or limitations) with HTML5 audio support in iOS and Android mobile and tablet platforms. In this article I am going to try to take a look at some of the ways we can overcome those limitations and quirks.
Swap Out Audio Source
We discussed the problem of single audio stream limitation where you can play from multiple sources. This can be fixed by swapping out the current audio source for another when required:
What’s the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.
1
2
3
4
5
6
var audio = document.getElementById(‘music’);
audio.play();
// Sometime Later
audio.src = ‘music_2.mp3’;
audio.play();
Note: There will be a slight delay initially while the new audio file loads! Hence this ain't a clean solution really, but a hack. There's a more appropriate hack to fix this initial delay problem along with the limitation called Audio Sprites.
Audio Sprites
You may already know about CSS Sprites where you combine all your images into a single image and then use them with proper pre-defined background positions for various portions (backgrounds for html elements) on your webpage. Similarly you can combine all your audio files into a single sprite with a 1 second gap/pause after each part. You'll need to make a note of the start and end times of each part (or just the start time and the length) in a JS object and then play them as required.
When the time that equals to the length of the track has elapsed, just pause the audio. It requires a simple logic, either use a setTimeout or add a timeupdate event handler.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// tracks object
var tracks = {
normal_jump: {
from: 0, to: 0.4
},
super_jump: {
from: 1, to: 2.2
},
space_belt: {
from: 3, to: 6.6
},
enemy: {
from: 7, to: 9
},
game_over: {
from: 10, to: 12.1
}
};
// name is the audio part name
var name = ‘normal_jump’;
// following code can be inside a function
var track = tracks[name];
audio_sprite.currentTime = track.from;
audio_sprite.play();
setTimeout(function() {
audio_sprite.pause();
}, (track.to * 1000) - (track.from * 1000));
// or use timeupdate
var handler = function() {
if (this.currentTime >= name.to)
this.pause();
};
audio_sprite.addEventListener(‘timeupdate’, handler, false);
Again, this ain't clean and you still cannot play multiple sounds or multiple parts simultaneously which is a common requirement in games. For example, at a particular point in time you may need to produce the sounds for player movements, enemies shooting and the player grabbing a powerup, at the same time.
Autoplay Issue
There's no fix to this issue, not even on iOS 6. You have to wait for user interaction (touch, click, etc. events) in order to start playing audio. Maybe you can present some options on the game splash screen where the user can select (with a click or tap) whether to start playing audio or not.
Trying out AppCache
Decided to give HTML5 AppCache a shot to try fix audio delay issues on ios and android.
On iOS 5 and 6 (chrome) and Jelly Bean (stock browser and chrome) there are delays initially when you play an audio file. But with appcache the issue is completely eradicated. So awesome! Although, when you load an audio for the first time in iOS Safari, the initial delay will be noticed. Hence, the problem is not entirely solved. Infact sometimes the audio doesn't start playing at all, no matter how many times you hit the play button (probably because it's not downloaded or something similar) which won't lead to save anything in appcache. So until the audio is downloaded entirely, appcache won't be triggered, which means subsequent requests will load resources over the wire (not from appcache).
Android has a weird issue in this case, when wifi is disconnected, play control will switch to pause control (on play) but no audio will be produced and sometimes there's no progress bar.
Laptop Repair Center in Banasavadi Barbed wireLaptop Service Center in MalleshwaramLaptop service center in YelahankaBAMS Colleges Bangalore admission
PES university direct admission