Skip to content

Commit 10d7db1

Browse files
committed
Update to 2.1.0
1 parent 39cc83e commit 10d7db1

33 files changed

+95
-43
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ion.sound",
3-
"version": "2.0.2",
3+
"version": "2.1.0",
44
"homepage": "https://github.com/IonDen/ion.sound",
55
"authors": [
66
{

ion-sound.jquery.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ion-sound",
3-
"version": "2.0.2",
3+
"version": "2.1.0",
44
"title": "Ion.Sound",
55
"description": "JavaScript plugin for playing sounds on user actions and events. Today websites are full of events (new mail, new chat-message, content update etc.). Often it is not enough to indicate this events only visually to get user attention. You need sounds! This library, made for playing small sounds, will help you with this task.",
66
"keywords": [
@@ -29,7 +29,7 @@
2929
"homepage": "https://github.com/IonDen/ion.sound",
3030
"docs": "https://github.com/IonDen/ion.sound/blob/master/readme.md",
3131
"demo": "http://ionden.com/a/plugins/ion.sound/en.html",
32-
"download": "http://ionden.com/a/plugins/ion.sound/ion.sound-2.0.2.zip",
32+
"download": "http://ionden.com/a/plugins/ion.sound/ion.sound-2.1.0.zip",
3333
"dependencies": {
3434
"jquery": ">=1.3"
3535
}

js/ion.sound.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Ion.Sound
3-
* version 2.0.2 Build 34
3+
* version 2.1.0 Build 42
44
* © 2014 Denis Ineshin | IonDen.com
55
*
66
* Project page: http://ionden.com/a/plugins/ion.sound/en.html
@@ -46,7 +46,6 @@ var ion = ion || {};
4646
var settings = {},
4747
sounds = {},
4848
sounds_num,
49-
can_play_mp3,
5049
ext,
5150
i;
5251

@@ -59,6 +58,7 @@ var ion = ion || {};
5958
this.loop = false;
6059
this.paused = false;
6160
this.sound = null;
61+
this.callback = null;
6262

6363
if ("volume" in options) {
6464
this.volume = +options.volume;
@@ -85,7 +85,7 @@ var ion = ion || {};
8585
obj = {};
8686
}
8787

88-
if (obj.volume) {
88+
if (obj.volume || obj.volume === 0) {
8989
this.volume = +obj.volume;
9090
this.sound.volume = this.volume;
9191
}
@@ -100,6 +100,10 @@ var ion = ion || {};
100100
this.loop = false;
101101
this._play();
102102
}
103+
104+
if (obj.onEnded && typeof obj.onEnded === "function") {
105+
this.callback = obj.onEnded;
106+
}
103107
},
104108

105109
_play: function () {
@@ -131,6 +135,10 @@ var ion = ion || {};
131135
this.loop -= 1;
132136
this._play();
133137
}
138+
139+
if (this.callback) {
140+
this.callback(this.name);
141+
}
134142
},
135143

136144
pause: function () {
@@ -158,17 +166,25 @@ var ion = ion || {};
158166

159167

160168
var checkSupport = function () {
161-
var sound_item = new Audio();
162-
can_play_mp3 = sound_item.canPlayType("audio/mpeg");
163-
164-
switch (can_play_mp3) {
165-
case "probably":
166-
case "maybe":
167-
ext = ".mp3";
168-
break;
169-
default:
170-
ext = ".ogg";
171-
break;
169+
var sound_item = new Audio(),
170+
can_play_mp3 = sound_item.canPlayType("audio/mpeg"),
171+
can_play_ogg = sound_item.canPlayType("audio/ogg; codecs='vorbis'"),
172+
can_play_aac = sound_item.canPlayType("audio/mp4; codecs='mp4a.40.2'");
173+
174+
if (can_play_mp3 === "probably") {
175+
ext = ".mp3";
176+
} else if (can_play_aac === "probably") {
177+
ext = ".ogg";
178+
} else if (can_play_ogg === "probably") {
179+
ext = ".aac";
180+
} else if (can_play_aac === "maybe") {
181+
ext = ".aac";
182+
} else if (can_play_mp3 === "maybe") {
183+
ext = ".ogg";
184+
} else if (can_play_ogg === "maybe") {
185+
ext = ".mp3";
186+
} else {
187+
ext = ".wav";
172188
}
173189

174190
sound_item = null;

js/ion.sound.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.ion.sound.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* jQuery.Ion.Sound
3-
* version 2.0.2 Build 34
3+
* version 2.1.0 Build 42
44
* © 2014 Denis Ineshin | IonDen.com
55
*
66
* Project page: http://ionden.com/a/plugins/ion.sound/en.html
@@ -44,7 +44,6 @@
4444
var settings = {},
4545
sounds = {},
4646
sounds_num,
47-
can_play_mp3,
4847
ext,
4948
i;
5049

@@ -57,6 +56,7 @@
5756
this.loop = false;
5857
this.paused = false;
5958
this.sound = null;
59+
this.callback = null;
6060

6161
if ("volume" in options) {
6262
this.volume = +options.volume;
@@ -83,7 +83,7 @@
8383
obj = {};
8484
}
8585

86-
if (obj.volume) {
86+
if (obj.volume || obj.volume === 0) {
8787
this.volume = +obj.volume;
8888
this.sound.volume = this.volume;
8989
}
@@ -98,6 +98,10 @@
9898
this.loop = false;
9999
this._play();
100100
}
101+
102+
if (obj.onEnded && typeof obj.onEnded === "function") {
103+
this.callback = obj.onEnded;
104+
}
101105
},
102106

103107
_play: function () {
@@ -129,6 +133,10 @@
129133
this.loop -= 1;
130134
this._play();
131135
}
136+
137+
if (this.callback) {
138+
this.callback(this.name);
139+
}
132140
},
133141

134142
pause: function () {
@@ -156,17 +164,25 @@
156164

157165

158166
var checkSupport = function () {
159-
var sound_item = new Audio();
160-
can_play_mp3 = sound_item.canPlayType("audio/mpeg");
161-
162-
switch (can_play_mp3) {
163-
case "probably":
164-
case "maybe":
165-
ext = ".mp3";
166-
break;
167-
default:
168-
ext = ".ogg";
169-
break;
167+
var sound_item = new Audio(),
168+
can_play_mp3 = sound_item.canPlayType("audio/mpeg"),
169+
can_play_ogg = sound_item.canPlayType("audio/ogg; codecs='vorbis'"),
170+
can_play_aac = sound_item.canPlayType("audio/mp4; codecs='mp4a.40.2'");
171+
172+
if (can_play_mp3 === "probably") {
173+
ext = ".mp3";
174+
} else if (can_play_aac === "probably") {
175+
ext = ".ogg";
176+
} else if (can_play_ogg === "probably") {
177+
ext = ".aac";
178+
} else if (can_play_aac === "maybe") {
179+
ext = ".aac";
180+
} else if (can_play_mp3 === "maybe") {
181+
ext = ".ogg";
182+
} else if (can_play_ogg === "maybe") {
183+
ext = ".mp3";
184+
} else {
185+
ext = ".wav";
170186
}
171187

172188
sound_item = null;

js/jquery.ion.sound.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Ion.Sound 2.0.2
1+
# Ion.Sound 2.1.0
22

33
> English description | <a href="readme.ru.md">Описание на русском</a>
44
55
JavaScript plugin for playing sounds on user actions and page events.
66
* <a href="http://ionden.com/a/plugins/ion.sound/en.html">Project page and demos</a>
7-
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-2.0.2.zip">Download ion.sound-2.0.2.zip</a>
7+
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-2.1.0.zip">Download ion.sound-2.1.0.zip</a>
88

99
***
1010

@@ -44,9 +44,11 @@ Import this libraries:
4444
Prepare sound-files (25 sounds are included) and put them in some folder (eg. "sounds"):
4545
* my_cool_sound.mp3
4646
* my_cool_sound.ogg
47+
* my_cool_sound.aac
4748

48-
It is not enough to have only Mp3-file, you should make Ogg-file too, because not all browsers support Mp3.<br/>
49-
You can easily convert you Mp3-s to Ogg-s at <a href="http://media.io/" target="_blank">Media.io</a> or at <a href="https://cloudconvert.org/formats#audio" target="_blank">CloudConvert.org</a>.
49+
It is not enough to have only MP3-file, you should make OGG and AAC-file too, because not all browsers support MP3.<br/>
50+
You can easily convert you MP3-s to OGG-s and AAC-s at <a href="http://media.io/" target="_blank">Media.io</a> or at <a href="https://cloudconvert.org/formats#audio" target="_blank">CloudConvert.org</a>.<br/>
51+
<i>AAC support was added to improve cross browser support of iOS 8.x devices (iPhone, iPad)</i>
5052

5153

5254
## Install with bower
@@ -159,6 +161,13 @@ ion.sound.play("my_cool_sound", {
159161
volume: 0.2,
160162
loop: 3
161163
});
164+
165+
// Add a callback on sound stops
166+
ion.sound.play("my_cool_sound", {
167+
onEnded: function (name) {
168+
console.log("Just finished: " + name);
169+
}
170+
});
162171
```
163172

164173
### ion.sound.pause
@@ -195,6 +204,7 @@ ion.sound.destroy();
195204

196205

197206
## Update history
207+
* 2.1.0: October 25, 2014 - Fixed bug #12. AAC files support. Callback onEnded.
198208
* 2.0.2: August 08, 2014 - New pause method. Add bower support
199209
* 2.0.1: August 01, 2014 - 2 versions of plugin, jQuery and non-jQuery
200210
* 2.0.0: June 31, 2014 - dropped jQuery dependency, new API, loop sounds feature

0 commit comments

Comments
 (0)