diff options
author | Michael Weibel <michael.weibel@gmail.com> | 2015-02-26 08:40:41 +0300 |
---|---|---|
committer | Michael Weibel <michael.weibel@gmail.com> | 2015-02-26 08:40:41 +0300 |
commit | fe41e0ecc7dd1f002a85f5b64c5019f869c4355f (patch) | |
tree | aa29a724bd39bc9148439620c7dce855b3083882 | |
parent | 3cf31599df19aa869176da78538f70a43e8d110f (diff) | |
parent | cdd223dd88c4b2d681959e206daff6e4b228c44e (diff) |
Merge branch 'notification_sound_update' of https://github.com/Sudrien/candy into Sudrien-notification_sound_update
Conflicts:
src/view/pane/message.js
-rw-r--r-- | .gitattributes | 3 | ||||
-rw-r--r-- | res/audioplayer.swf | bin | 2680 -> 0 bytes | |||
-rw-r--r-- | res/notify.m4a | bin | 0 -> 4495 bytes | |||
-rw-r--r-- | res/notify.mp3 | bin | 1095 -> 1149 bytes | |||
-rw-r--r-- | res/notify.ogg | bin | 0 -> 4040 bytes | |||
-rw-r--r-- | src/view.js | 3 | ||||
-rw-r--r-- | src/view/pane/chat.js | 31 | ||||
-rw-r--r-- | src/view/template.js | 8 |
8 files changed, 26 insertions, 19 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6915f9e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +res/notify.m4a binary +res/notify.ogg binary +res/notify.mp3 binary diff --git a/res/audioplayer.swf b/res/audioplayer.swf Binary files differdeleted file mode 100644 index 72390d4..0000000 --- a/res/audioplayer.swf +++ /dev/null diff --git a/res/notify.m4a b/res/notify.m4a Binary files differnew file mode 100644 index 0000000..b090b29 --- /dev/null +++ b/res/notify.m4a diff --git a/res/notify.mp3 b/res/notify.mp3 Binary files differindex c00d997..c7f7495 100644 --- a/res/notify.mp3 +++ b/res/notify.mp3 diff --git a/res/notify.ogg b/res/notify.ogg Binary files differnew file mode 100644 index 0000000..c6663d3 --- /dev/null +++ b/res/notify.ogg diff --git a/src/view.js b/src/view.js index f438670..b670302 100644 --- a/src/view.js +++ b/src/view.js @@ -137,8 +137,7 @@ Candy.View = (function(self, $) { tabs: Candy.View.Template.Chat.tabs, rooms: Candy.View.Template.Chat.rooms, modal: Candy.View.Template.Chat.modal, - toolbar: Candy.View.Template.Chat.toolbar, - soundcontrol: Candy.View.Template.Chat.soundcontrol + toolbar: Candy.View.Template.Chat.toolbar })); // ... and let the elements dance. diff --git a/src/view/pane/chat.js b/src/view/pane/chat.js index 998d3ca..cf154ea 100644 --- a/src/view/pane/chat.js +++ b/src/view/pane/chat.js @@ -282,7 +282,7 @@ Candy.View.Pane = (function(self, $) { * Chat toolbar for things like emoticons toolbar, room management etc. */ Toolbar: { - _supportsNativeAudio: false, + _supportsNativeAudio: null, /** Function: init * Register handler and enable or disable sound and status messages. @@ -293,9 +293,20 @@ Candy.View.Pane = (function(self, $) { e.stopPropagation(); }); $('#chat-autoscroll-control').click(self.Chat.Toolbar.onAutoscrollControlClick); - - var a = document.createElement('audio'); - self.Chat.Toolbar._supportsNativeAudio = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); + try { + if( !!document.createElement('audio').canPlayType ) { + var a = document.createElement('audio'); + if( !!(a.canPlayType('audio/mpeg;').replace(/no/, '')) ) { + self.Chat.Toolbar._supportsNativeAudio = "mp3"; + } + else if( !!(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '')) ) { + self.Chat.Toolbar._supportsNativeAudio = "ogg"; + } + else if ( !!(a.canPlayType('audio/mp4; codecs="mp4a.40.2"').replace(/no/, '')) ) { + self.Chat.Toolbar._supportsNativeAudio = "m4a"; + } + } + } catch(e){ } $('#chat-sound-control').click(self.Chat.Toolbar.onSoundControlClick); if(Candy.Util.cookieExists('candy-nosound')) { $('#chat-sound-control').click(); @@ -345,19 +356,19 @@ Candy.View.Pane = (function(self, $) { }, /** Function: onPlaySound - * Sound play event handler. Uses native (HTML5) audio if supported + * Sound play event handler. Uses native (HTML5) audio if supported, + * otherwise it will attempt to use bgsound with autostart. * * Don't call this method directly. Call `playSound()` instead. * `playSound()` will only call this method if sound is enabled. */ onPlaySound: function() { try { - if(self.Chat.Toolbar._supportsNativeAudio) { - new Audio(Candy.View.getOptions().assets + 'notify.mp3').play(); + if(self.Chat.Toolbar._supportsNativeAudio !== null) { + new Audio(Candy.View.getOptions().assets + 'notify.' + self.Chat.Toolbar._supportsNativeAudio).play(); } else { - var chatSoundPlayer = document.getElementById('chat-sound-player'); - chatSoundPlayer.SetVariable('method:stop', ''); - chatSoundPlayer.SetVariable('method:play', ''); + $('#chat-sound-control bgsound').remove(); + $('<bgsound/>').attr({ src: Candy.View.getOptions().assets + 'notify.mp3', loop: 1, autostart: true }).appendTo("#chat-sound-control"); } } catch (e) {} }, diff --git a/src/view/template.js b/src/view/template.js index 3df2adb..0d51855 100644 --- a/src/view/template.js +++ b/src/view/template.js @@ -43,18 +43,12 @@ Candy.View.Template = (function(self){ '<span class="spacer">•</span>{{subject}} {{message}}</div></li>', toolbar: '<ul id="chat-toolbar">' + '<li id="emoticons-icon" data-tooltip="{{tooltipEmoticons}}"></li>' + - '<li id="chat-sound-control" class="checked" data-tooltip="{{tooltipSound}}">{{> soundcontrol}}</li>' + + '<li id="chat-sound-control" class="checked" data-tooltip="{{tooltipSound}}"></li>' + '<li id="chat-autoscroll-control" class="checked" data-tooltip="{{tooltipAutoscroll}}"></li>' + '<li class="checked" id="chat-statusmessage-control" data-tooltip="{{tooltipStatusmessage}}">' + '</li><li class="context" data-tooltip="{{tooltipAdministration}}"></li>' + '<li class="usercount" data-tooltip="{{tooltipUsercount}}">' + '<span id="chat-usercount"></span></li></ul>', - soundcontrol: '<script type="text/javascript">var audioplayerListener = new Object();' + - ' audioplayerListener.onInit = function() { };' + - '</script><object id="chat-sound-player" type="application/x-shockwave-flash" data="{{assetsPath}}audioplayer.swf"' + - ' width="0" height="0"><param name="movie" value="{{assetsPath}}audioplayer.swf" /><param name="AllowScriptAccess"' + - ' value="always" /><param name="FlashVars" value="listener=audioplayerListener&mp3={{assetsPath}}notify.mp3" />' + - '</object>', Context: { menu: '<div id="context-menu"><i class="arrow arrow-top"></i>' + '<ul></ul><i class="arrow arrow-bottom"></i></div>', |