Skip to content

Commit

Permalink
Update to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IonDen committed Oct 13, 2013
1 parent 3a722f4 commit 81407bd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
6 changes: 3 additions & 3 deletions ion-sound.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion-sound",
"version": "1.1.0",
"version": "1.2.0",
"title": "Ion.Sound",
"description": "Plugin for playing sounds on 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,8 +29,8 @@
"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-1.1.0.zip",
"download": "http://ionden.com/a/plugins/ion.sound/ion.sound-1.2.0.zip",
"dependencies": {
"jquery": ">=1.9"
"jquery": ">=1.6"
}
}
48 changes: 29 additions & 19 deletions js/ion-sound/ion.sound.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Ion.Sound
// version 1.1.0 Build: 13
// version 1.2.0 Build: 16
// © 2013 Denis Ineshin | IonDen.com
//
// Project page: http://ionden.com/a/plugins/ion.sound/en.html
Expand All @@ -11,7 +11,7 @@

(function ($) {

if($.ionSound) {
if ($.ionSound) {
return;
}

Expand All @@ -26,39 +26,49 @@
playing = false;


var createSound = function(name){
var createSound = function (soundInfo) {
var name,
volume;

if (soundInfo.indexOf(":") !== -1) {
name = soundInfo.split(":")[0];
volume = soundInfo.split(":")[1];
} else {
name = soundInfo;
}

sounds[name] = new Audio();
canMp3 = sounds[name].canPlayType("audio/mp3");
if(canMp3 === "probably" || canMp3 === "maybe") {
if (canMp3 === "probably" || canMp3 === "maybe") {
url = settings.path + name + ".mp3";
} else {
url = settings.path + name + ".ogg";
}

$(sounds[name]).prop("src", url);
sounds[name].load();
sounds[name].volume = settings.volume;
sounds[name].volume = volume || settings.volume;
};


var playSound = function(name){
var playSound = function (name) {
var $sound = sounds[name],
playingInt;

if(typeof $sound === "object" && $sound !== null) {
if (typeof $sound === "object" && $sound !== null) {

if(!settings.multiPlay && !playing) {
if (!settings.multiPlay && !playing) {
$sound.play();
playing = true;

playingInt = setInterval(function(){
if($sound.ended) {
playingInt = setInterval(function () {
if ($sound.ended) {
clearInterval(playingInt);
playing = false;
}
}, 250);
} else if(settings.multiPlay) {
if($sound.ended) {
} else if (settings.multiPlay) {
if ($sound.ended) {
$sound.play();
} else {
try {
Expand All @@ -73,7 +83,7 @@


// Plugin methods
$.ionSound = function(options){
$.ionSound = function (options) {

settings = $.extend({
sounds: [
Expand All @@ -86,24 +96,24 @@

soundsNum = settings.sounds.length;

if(typeof Audio === "function" || typeof Audio === "object") {
for(i = 0; i < soundsNum; i += 1){
if (typeof Audio === "function" || typeof Audio === "object") {
for (i = 0; i < soundsNum; i += 1) {
createSound(settings.sounds[i]);
}
}

$.ionSound.play = function(name) {
$.ionSound.play = function (name) {
playSound(name);
};
};


$.ionSound.destroy = function() {
for(i = 0; i < soundsNum; i += 1){
$.ionSound.destroy = function () {
for (i = 0; i < soundsNum; i += 1) {
sounds[settings.sounds[i]] = null;
}
soundsNum = 0;
$.ionSound.play = function(){};
$.ionSound.play = function () {};
};

}(jQuery));
5 changes: 2 additions & 3 deletions js/ion-sound/ion.sound.min.js

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

15 changes: 8 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Ion.Sound 1.1.0
# Ion.Sound 1.2.0

> English description | <a href="readme.ru.md">Описание на русском</a>
Plugin for playing sounds on 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-1.1.0.zip">Download ion.sound-1.1.0.zip</a>
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-1.2.0.zip">Download ion.sound-1.2.0.zip</a>

***

Expand Down Expand Up @@ -62,8 +62,8 @@ $.ionSound.play("my_cool_sound");
<tbody>
<tr>
<td>sounds</td>
<td>["water droplet"]</td>
<td>Optional property, you can set your own sounds collection here.</td>
<td>["water_droplet:0.5"]</td>
<td>Optional property, you can set your own sounds collection here. It is array.<br/>:0.5 - optional individual volume. Example: <code>sound_name:0.2</code></td>
</tr>
<tr>
<td>path</td>
Expand All @@ -88,12 +88,12 @@ An example of a customised plugin:
$.ionSound({
sounds: [ // set needed sounds names
"beer_can_opening",
"bell_ring",
"bell_ring:0.3", // :0.3 - individual volume
"branch_break",
"metal_plate",
"pop_cork",
"pop_cork:0.8", // :0.8 - individual volume
"staple_gun",
"water_droplet"
"water_droplet:0.4" // :0.4 - individual volume
],
path: "sounds/", // set path to sounds
multiPlay: false, // playing only 1 sound at once
Expand All @@ -117,6 +117,7 @@ $.ionSound.destroy();


## Update history
* October 13, 2013 - now you can set individual volume for any sound. Improved test environment.
* September 21, 2013 - plugin moved to jQuery namespace, new method and 10 new sounds
* September 08, 2013 - iOS not playing sound bug fix
* September 08, 2013 - Little enhancement
Expand Down
13 changes: 7 additions & 6 deletions readme.ru.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Ion.Sound 1.1.0
# Ion.Sound 1.2.0

> <a href="readme.md">English description</a> | Описание на русском
Плагин для воспроизведения звуков событий.
* <a href="http://ionden.com/a/plugins/ion.sound/index.html">Сайт проекта и демо</a>
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-1.1.0.zip">Скачать ion.sound-1.1.0.zip</a>
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-1.2.0.zip">Скачать ion.sound-1.2.0.zip</a>

***

Expand Down Expand Up @@ -60,8 +60,8 @@ $.ionSound.play("my_cool_sound");
<tbody>
<tr>
<td>sounds</td>
<td>[Массив из 15 звуков]</td>
<td>Не обязательный параметр, позволяет задать набор подключаемых звуков</td>
<td>["water_droplet:0.5"]</td>
<td>Не обязательный параметр, позволяет задать набор подключаемых звуков в виде массива.<br/>:0.5 - не обязательный параметр, задает индивидуальную громкость. Например <code>Sound_name:0.8</code></td>
</tr>
<tr>
<td>path</td>
Expand All @@ -86,9 +86,9 @@ $.ionSound.play("my_cool_sound");
$.ionSound({
sounds: [ // указываем нужные названия звуков
"beer_can_opening",
"bell_ring",
"bell_ring:0.3", // индивидуальная громкость 0.3
"branch_break",
"metal_plate",
"metal_plate:0.4", // индивидуальная громкость 0.4
"pop_cork",
"staple_gun",
"water_droplet"
Expand All @@ -114,6 +114,7 @@ $.ionSound.destroy();


## История обновлений
* 13.10.2013 - добавлена возмоность устанавливать индивидуальную громкость для каждого звука. Улучшено тестовое окружение
* 21.09.2013 - плагин переехал в простарнство имен jQuery, добавлен новый метод, добавлено 10 звуков
* 08.09.2013 - исправлен баг в iOS
* 08.09.2013 - небольшое улучшение
Expand Down

0 comments on commit 81407bd

Please sign in to comment.