Skip to content

Commit

Permalink
Update to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IonDen committed Sep 21, 2013
1 parent a7cfa35 commit 3a722f4
Show file tree
Hide file tree
Showing 25 changed files with 118 additions and 102 deletions.
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": "1.0.2",
"version": "1.1.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,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-1.0.2.zip",
"download": "http://ionden.com/a/plugins/ion.sound/ion.sound-1.1.0.zip",
"dependencies": {
"jquery": ">=1.9"
}
Expand Down
138 changes: 74 additions & 64 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.0.2 Build: 6
// version 1.1.0 Build: 13
// © 2013 Denis Ineshin | IonDen.com
//
// Project page: http://ionden.com/a/plugins/ion.sound/en.html
Expand All @@ -9,81 +9,55 @@
// http://ionden.com/a/plugins/licence-en.html
// =====================================================================================================================

var ion = ion || {};
(function ($) {

ion.sound = {
init: function(options){
var settings = $.extend({
sounds: [
"beer_can_opening",
"bell_ring",
"branch_break",
"button_click",
"button_click_on",
"button_push",
"button_tiny",
"camera_flashing",
"computer_error",
"door_bell",
"light_bulb_breaking",
"metal_plate",
"pop_cork",
"staple_gun",
"water_droplet"
],
path: "static/sounds/",
multiPlay: true,
volume: "0.5"
}, options);
if($.ionSound) {
return;
}

var i,
soundsNum = settings.sounds.length,
self = this,
canMp3,
url;

this.sounds = {};
this.playing = false;
this.multiPlay = settings.multiPlay;

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

$(self.sounds[name]).prop("src", url);
self.sounds[name].load();
self.sounds[name].volume = settings.volume;
};
var settings = {},
soundsNum,
canMp3,
url,
i,

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


var createSound = function(name){
sounds[name] = new Audio();
canMp3 = sounds[name].canPlayType("audio/mp3");
if(canMp3 === "probably" || canMp3 === "maybe") {
url = settings.path + name + ".mp3";
} else {
url = settings.path + name + ".ogg";
}
},
play: function(name){
var $sound = this.sounds[name],
playingInt,
self = this;

if(typeof $sound === "object") {
$(sounds[name]).prop("src", url);
sounds[name].load();
sounds[name].volume = settings.volume;
};


if(!this.multiPlay && !this.playing) {
var playSound = function(name){
var $sound = sounds[name],
playingInt;

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

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

playingInt = setInterval(function(){
if($sound.ended) {
clearInterval(playingInt);
self.playing = false;
playing = false;
}
}, 250);
} else if(this.multiPlay) {
} else if(settings.multiPlay) {
if($sound.ended) {
$sound.play();
} else {
Expand All @@ -95,5 +69,41 @@ ion.sound = {
}

}
}
};
};


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

settings = $.extend({
sounds: [
"water_droplet"
],
path: "static/sounds/",
multiPlay: true,
volume: "0.5"
}, options);

soundsNum = settings.sounds.length;

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

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


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

}(jQuery));
6 changes: 3 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.

39 changes: 21 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Ion.Sound 1.0.2
# Ion.Sound 1.1.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.0.2.zip">Download ion.sound-1.0.2.zip</a>
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-1.1.0.zip">Download ion.sound-1.1.0.zip</a>

***

## Description
* Crossbrowser support: Google Chrome, Mozilla Firefox, Opera, Safari, IE(9.0+) and mobile browsers
* <a href="https://github.com/IonDen/ion.sound">GitHub Page</a>.
* Ion.Sound freely distributed under terms of <a href="http://ionden.com/a/plugins/licence-en.html" target="_blank">MIT licence</a>.
* Ion.Sound includes 15 free sounds
* Ion.Sound includes 25 free sounds

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.

Expand All @@ -26,7 +26,7 @@ Import this libraries:
* jQuery
* ion.sound.min.js

Prepare sound-files (15 sounds are included) and put them in some folder (eg. "sounds"):
Prepare sound-files (25 sounds are included) and put them in some folder (eg. "sounds"):
* my_cool_sound.mp3
* my_cool_sound.ogg

Expand All @@ -37,12 +37,16 @@ You can easily convert you Mp3-s to Ogg-s at <a href="http://media.io/" target="
## Initialisation
To initialise plugin call this method:
```javascript
ion.sound.init();
$.ionSound({
sounds: [
"my_cool_sound"
]
});
```

And play sound!
```javascript
ion.sound.play("my_cool_sound");
$.ionSound.play("my_cool_sound");
```


Expand All @@ -58,7 +62,7 @@ ion.sound.play("my_cool_sound");
<tbody>
<tr>
<td>sounds</td>
<td>[Array of 15 sounds]</td>
<td>["water droplet"]</td>
<td>Optional property, you can set your own sounds collection here.</td>
</tr>
<tr>
Expand All @@ -81,19 +85,11 @@ ion.sound.play("my_cool_sound");

An example of a customised plugin:
```javascript
ion.sound.init({
sounds: [ // set sounds names
$.ionSound({
sounds: [ // set needed sounds names
"beer_can_opening",
"bell_ring",
"branch_break",
"button_click",
"button_click_on",
"button_push",
"button_tiny",
"camera_flashing",
"computer_error",
"door_bell",
"light_bulb_breaking",
"metal_plate",
"pop_cork",
"staple_gun",
Expand All @@ -109,12 +105,19 @@ ion.sound.init({
Playing sound on button click:
```javascript
$("#myButton").on("click", function(){
ion.sound.play("button_tiny");
$.ionSound.play("button_tiny");
});
```


Destroying the plugin:
```javascript
$.ionSound.destroy();
```


## Update history
* 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
* September 07, 2013 - Plugin release
33 changes: 18 additions & 15 deletions readme.ru.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Ion.Sound 1.0.2
# Ion.Sound 1.1.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.0.2.zip">Скачать ion.sound-1.0.2.zip</a>
* <a href="http://ionden.com/a/plugins/ion.sound/ion.sound-1.1.0.zip">Скачать ion.sound-1.1.0.zip</a>

***

Expand Down Expand Up @@ -36,12 +36,16 @@
## Инициализация
Инициализируем плагин:
```javascript
ion.sound.init();
$.ionSound({
sounds: [
"my_cool_sound"
]
});
```

Играем звук:
```javascript
ion.sound.play("my_cool_sound");
$.ionSound.play("my_cool_sound");
```

## Параметры
Expand Down Expand Up @@ -79,19 +83,11 @@ ion.sound.play("my_cool_sound");

Пример плагина подключенного с параметрами:
```javascript
ion.sound.init({
sounds: [ // указываем названия звуков
$.ionSound({
sounds: [ // указываем нужные названия звуков
"beer_can_opening",
"bell_ring",
"branch_break",
"button_click",
"button_click_on",
"button_push",
"button_tiny",
"camera_flashing",
"computer_error",
"door_bell",
"light_bulb_breaking",
"metal_plate",
"pop_cork",
"staple_gun",
Expand All @@ -106,12 +102,19 @@ ion.sound.init({
Проигрываем один из звуков при нажатии на кнопку:
```javascript
$("#myButton").on("click", function(){
ion.sound.play("button_tiny");
$.ionSound.play("button_tiny");
});
```


Прекращаем работу плагина:
```javascript
$.ionSound.destroy();
```


## История обновлений
* 21.09.2013 - плагин переехал в простарнство имен jQuery, добавлен новый метод, добавлено 10 звуков
* 08.09.2013 - исправлен баг в iOS
* 08.09.2013 - небольшое улучшение
* 07.09.2013 - релиз плагина
Binary file added sounds/camera_flashing_2.mp3
Binary file not shown.
Binary file added sounds/camera_flashing_2.ogg
Binary file not shown.
Binary file added sounds/cd_tray.mp3
Binary file not shown.
Binary file added sounds/cd_tray.ogg
Binary file not shown.
Binary file added sounds/door_bump.mp3
Binary file not shown.
Binary file added sounds/door_bump.ogg
Binary file not shown.
Binary file added sounds/glass.mp3
Binary file not shown.
Binary file added sounds/glass.ogg
Binary file not shown.
Binary file added sounds/keyboard_desk.mp3
Binary file not shown.
Binary file added sounds/keyboard_desk.ogg
Binary file not shown.
Binary file added sounds/metal_plate_2.mp3
Binary file not shown.
Binary file added sounds/metal_plate_2.ogg
Binary file not shown.
Binary file added sounds/snap.mp3
Binary file not shown.
Binary file added sounds/snap.ogg
Binary file not shown.
Binary file added sounds/tap.mp3
Binary file not shown.
Binary file added sounds/tap.ogg
Binary file not shown.
Binary file added sounds/water_droplet_2.mp3
Binary file not shown.
Binary file added sounds/water_droplet_2.ogg
Binary file not shown.
Binary file added sounds/water_droplet_3.mp3
Binary file not shown.
Binary file added sounds/water_droplet_3.ogg
Binary file not shown.

0 comments on commit 3a722f4

Please sign in to comment.