Skip to content

Commit

Permalink
Update to 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IonDen committed Oct 25, 2014
1 parent 39cc83e commit 10d7db1
Show file tree
Hide file tree
Showing 33 changed files with 95 additions and 43 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion.sound",
"version": "2.0.2",
"version": "2.1.0",
"homepage": "https://github.com/IonDen/ion.sound",
"authors": [
{
Expand Down
4 changes: 2 additions & 2 deletions ion-sound.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion-sound",
"version": "2.0.2",
"version": "2.1.0",
"title": "Ion.Sound",
"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.",
"keywords": [
Expand Down Expand Up @@ -29,7 +29,7 @@
"homepage": "https://github.com/IonDen/ion.sound",
"docs": "https://github.com/IonDen/ion.sound/blob/master/readme.md",
"demo": "http://ionden.com/a/plugins/ion.sound/en.html",
"download": "http://ionden.com/a/plugins/ion.sound/ion.sound-2.0.2.zip",
"download": "http://ionden.com/a/plugins/ion.sound/ion.sound-2.1.0.zip",
"dependencies": {
"jquery": ">=1.3"
}
Expand Down
44 changes: 30 additions & 14 deletions js/ion.sound.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Ion.Sound
* version 2.0.2 Build 34
* version 2.1.0 Build 42
* © 2014 Denis Ineshin | IonDen.com
*
* Project page: http://ionden.com/a/plugins/ion.sound/en.html
Expand Down Expand Up @@ -46,7 +46,6 @@ var ion = ion || {};
var settings = {},
sounds = {},
sounds_num,
can_play_mp3,
ext,
i;

Expand All @@ -59,6 +58,7 @@ var ion = ion || {};
this.loop = false;
this.paused = false;
this.sound = null;
this.callback = null;

if ("volume" in options) {
this.volume = +options.volume;
Expand All @@ -85,7 +85,7 @@ var ion = ion || {};
obj = {};
}

if (obj.volume) {
if (obj.volume || obj.volume === 0) {
this.volume = +obj.volume;
this.sound.volume = this.volume;
}
Expand All @@ -100,6 +100,10 @@ var ion = ion || {};
this.loop = false;
this._play();
}

if (obj.onEnded && typeof obj.onEnded === "function") {
this.callback = obj.onEnded;
}
},

_play: function () {
Expand Down Expand Up @@ -131,6 +135,10 @@ var ion = ion || {};
this.loop -= 1;
this._play();
}

if (this.callback) {
this.callback(this.name);
}
},

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


var checkSupport = function () {
var sound_item = new Audio();
can_play_mp3 = sound_item.canPlayType("audio/mpeg");

switch (can_play_mp3) {
case "probably":
case "maybe":
ext = ".mp3";
break;
default:
ext = ".ogg";
break;
var sound_item = new Audio(),
can_play_mp3 = sound_item.canPlayType("audio/mpeg"),
can_play_ogg = sound_item.canPlayType("audio/ogg; codecs='vorbis'"),
can_play_aac = sound_item.canPlayType("audio/mp4; codecs='mp4a.40.2'");

if (can_play_mp3 === "probably") {
ext = ".mp3";
} else if (can_play_aac === "probably") {
ext = ".ogg";
} else if (can_play_ogg === "probably") {
ext = ".aac";
} else if (can_play_aac === "maybe") {
ext = ".aac";
} else if (can_play_mp3 === "maybe") {
ext = ".ogg";
} else if (can_play_ogg === "maybe") {
ext = ".mp3";
} else {
ext = ".wav";
}

sound_item = null;
Expand Down
4 changes: 2 additions & 2 deletions js/ion.sound.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 30 additions & 14 deletions js/jquery.ion.sound.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* jQuery.Ion.Sound
* version 2.0.2 Build 34
* version 2.1.0 Build 42
* © 2014 Denis Ineshin | IonDen.com
*
* Project page: http://ionden.com/a/plugins/ion.sound/en.html
Expand Down Expand Up @@ -44,7 +44,6 @@
var settings = {},
sounds = {},
sounds_num,
can_play_mp3,
ext,
i;

Expand All @@ -57,6 +56,7 @@
this.loop = false;
this.paused = false;
this.sound = null;
this.callback = null;

if ("volume" in options) {
this.volume = +options.volume;
Expand All @@ -83,7 +83,7 @@
obj = {};
}

if (obj.volume) {
if (obj.volume || obj.volume === 0) {
this.volume = +obj.volume;
this.sound.volume = this.volume;
}
Expand All @@ -98,6 +98,10 @@
this.loop = false;
this._play();
}

if (obj.onEnded && typeof obj.onEnded === "function") {
this.callback = obj.onEnded;
}
},

_play: function () {
Expand Down Expand Up @@ -129,6 +133,10 @@
this.loop -= 1;
this._play();
}

if (this.callback) {
this.callback(this.name);
}
},

pause: function () {
Expand Down Expand Up @@ -156,17 +164,25 @@


var checkSupport = function () {
var sound_item = new Audio();
can_play_mp3 = sound_item.canPlayType("audio/mpeg");

switch (can_play_mp3) {
case "probably":
case "maybe":
ext = ".mp3";
break;
default:
ext = ".ogg";
break;
var sound_item = new Audio(),
can_play_mp3 = sound_item.canPlayType("audio/mpeg"),
can_play_ogg = sound_item.canPlayType("audio/ogg; codecs='vorbis'"),
can_play_aac = sound_item.canPlayType("audio/mp4; codecs='mp4a.40.2'");

if (can_play_mp3 === "probably") {
ext = ".mp3";
} else if (can_play_aac === "probably") {
ext = ".ogg";
} else if (can_play_ogg === "probably") {
ext = ".aac";
} else if (can_play_aac === "maybe") {
ext = ".aac";
} else if (can_play_mp3 === "maybe") {
ext = ".ogg";
} else if (can_play_ogg === "maybe") {
ext = ".mp3";
} else {
ext = ".wav";
}

sound_item = null;
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.ion.sound.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Ion.Sound 2.0.2
# Ion.Sound 2.1.0

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

***

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

It is not enough to have only Mp3-file, you should make Ogg-file too, because not all browsers support Mp3.<br/>
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>.
It is not enough to have only MP3-file, you should make OGG and AAC-file too, because not all browsers support MP3.<br/>
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/>
<i>AAC support was added to improve cross browser support of iOS 8.x devices (iPhone, iPad)</i>


## Install with bower
Expand Down Expand Up @@ -159,6 +161,13 @@ ion.sound.play("my_cool_sound", {
volume: 0.2,
loop: 3
});

// Add a callback on sound stops
ion.sound.play("my_cool_sound", {
onEnded: function (name) {
console.log("Just finished: " + name);
}
});
```

### ion.sound.pause
Expand Down Expand Up @@ -195,6 +204,7 @@ ion.sound.destroy();


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

0 comments on commit 10d7db1

Please sign in to comment.