187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/audio-js.css:
--------------------------------------------------------------------------------
1 | /*
2 | AudioJS Default Styles (http://videojs.com)
3 | Version 2.0.2
4 |
5 | REQUIRED STYLES (be careful overriding)
6 | ================================================================================ */
7 | /* Box containing audio, controls, and download links.
8 | Will be set to the width of the audio element through JS
9 | If you want to add some kind of frame or special positioning, use another containing element, not audio-js-box. */
10 | .audio-js-box { text-align: left; position: relative; line-height: 0 !important; margin: 0; padding: 0 !important; border: none !important; }
11 |
12 | /* Audio Element */
13 | .audio-js-box audio { width: 0; height: 0; display: block;}
14 | .audio-js-box.ajs-ios audio{ width: 100%; height: 3em;}
15 |
16 | /* Subtiles Style */
17 | .audio-js-box .ajs-subtitles { color: #fff; font-size: 20px; text-align: center; position: absolute; bottom: 40px; left: 0; right: 0; }
18 |
19 | /* Styles Loaded Check */
20 | .ajs-styles-check { height: 5px; position: absolute; }
21 |
22 | /* DEFAULT SKIN (override in another file)
23 | ================================================================================
24 | Using all CSS to draw the controls. Images could be used if desired.
25 | Instead of editing this file, I recommend creating your own skin CSS file to be included after this file,
26 | so you can upgrade to newer versions easier. */
27 |
28 | /* Controls Layout
29 | Using absolute positioning to position controls */
30 | .audio-js-box .ajs-controls {
31 | position: relative; margin: 0; opacity: 0.85; color: #fff;
32 | display: none; /* Start hidden */
33 | left: 0; right: 0; /* 100% width of audio-js-box */
34 | width: 100%;
35 | bottom: 0px; /* Distance from the bottom of the box/audio. Keep 0. Use height to add more bottom margin. */
36 | height: 35px; /* Including any margin you want above or below control items */
37 | padding: 0; /* Controls are absolutely position, so no padding necessary */
38 | -webkit-transition: opacity 0.5s linear;
39 | -moz-transition: opacity 0.5s linear;
40 | -o-transition: opacity 0.5s linear;
41 | -ms-transition: opacity 0.5s linear;
42 | transition: opacity 0.5s linear;
43 | }
44 |
45 | .ajs-hide {
46 | -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
47 | opacity: 0 !important;
48 | }
49 |
50 | .ajs-show {
51 | -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; /* IE8 */
52 | opacity: 1 !important;
53 | }
54 |
55 | .audio-js-box .ajs-controls > div { /* Direct div children of control bar */
56 | position: absolute; /* Use top, bottom, left, and right to specifically position the control. */
57 | text-align: center; margin: 0; padding: 0;
58 | height: 25px; /* Default height of individual controls */
59 | top: 5px; /* Top margin to put space between audio and controls when controls are below */
60 |
61 | /* CSS Background Gradients, Using to give the aqua-ish look. */
62 | background-color: #0B151A;
63 | background: #1F3744 -webkit-gradient(linear, left top, left bottom, from(#0B151A), to(#1F3744)) left 12px;
64 | background: #1F3744 -moz-linear-gradient(top, #0B151A, #1F3744) left 12px;
65 |
66 | /* CSS Curved Corners */
67 | -webkit-border-radius: 5px; border-radius: 5px;
68 |
69 | /* CSS Shadows */
70 | -webkit-box-shadow: 1px 1px 2px #000; -moz-box-shadow: 1px 1px 2px #000; box-shadow: 1px 1px 2px #000;
71 | }
72 |
73 | /* Placement of Control Items
74 | - Left side of pogress bar, use left & width
75 | - Rigth side of progress bar, use right & width
76 | - Expand with the audio (like progress bar) use left & right */
77 | .ajs-controls > div.ajs-play-control { left: 5px; width: 25px; }
78 | .ajs-controls > div.ajs-progress-control { left: 35px; right: 125px; } /* Using left & right so it expands with the width of the audio */
79 | .ajs-controls > div.ajs-time-control { width: 75px; right: 50px; } /* Time control and progress bar are combined to look like one */
80 | .ajs-controls > div.ajs-volume-control { width: 50px; right: 5px; }
81 |
82 | /* Removing curved corners on progress control and time control to join them. */
83 | .ajs-controls > div.ajs-progress-control {
84 | -webkit-border-top-right-radius: 0; border-top-right-radius: 0;
85 | -webkit-border-bottom-right-radius: 0; border-bottom-right-radius: 0;
86 | }
87 | .ajs-controls > div.ajs-time-control {
88 | -webkit-border-top-left-radius: 0; border-top-left-radius: 0;
89 | -webkit-border-bottom-left-radius: 0; border-bottom-left-radius: 0;
90 | }
91 |
92 | /* Play/Pause
93 | -------------------------------------------------------------------------------- */
94 | .ajs-play-control { cursor: pointer !important; }
95 | /* Play Icon */
96 | .ajs-play-control span { display: block; font-size: 0; line-height: 0; }
97 | .ajs-paused .ajs-play-control span {
98 | width: 0; height: 0; margin: 8px 0 0 8px;
99 | /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
100 | border-left: 10px solid #fff; /* Width & Color of play icon */
101 | /* Height of play icon is total top & bottom border widths. Color is transparent. */
102 | border-top: 5px solid rgba(0,0,0,0); border-bottom: 5px solid rgba(0,0,0,0);
103 | }
104 | .ajs-playing .ajs-play-control span {
105 | width: 3px; height: 10px; margin: 8px auto 0;
106 | /* Drawing the pause bars with borders */
107 | border-top: 0px; border-left: 3px solid #fff; border-bottom: 0px; border-right: 3px solid #fff;
108 | }
109 |
110 | /* Progress
111 | -------------------------------------------------------------------------------- */
112 | .ajs-progress-holder { /* Box containing play and load progresses */
113 | position: relative; padding: 0; overflow:hidden; cursor: pointer !important;
114 | height: 9px; border: 1px solid #777;
115 | margin: 7px 1px 0 5px; /* Placement within the progress control item */
116 | -webkit-border-radius: 5px; border-radius: 5px;
117 | }
118 | .ajs-progress-holder div { /* Progress Bars */
119 | position: absolute; display: block; width: 0; height: 9px; margin: 0; padding: 0;
120 | -webkit-border-radius: 5px; border-radius: 5px;
121 | }
122 | .ajs-play-progress {
123 | /* CSS Gradient */
124 | background: #fff;
125 | background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#777));
126 | background: -moz-linear-gradient(top, #fff, #777);
127 | }
128 | .ajs-load-progress {
129 | opacity: 0.8;
130 | /* CSS Gradient */
131 | background-color: #555;
132 | background: -webkit-gradient(linear, left top, left bottom, from(#555), to(#aaa));
133 | background: -moz-linear-gradient(top, #555, #aaa);
134 | }
135 |
136 | /* Time Display
137 | -------------------------------------------------------------------------------- */
138 | .ajs-controls .ajs-time-control { font-size: 10px; line-height: 1; font-weight: normal; font-family: Helvetica, Arial, sans-serif; }
139 | .ajs-controls .ajs-time-control span { line-height: 25px; /* Centering vertically */ }
140 |
141 | /* Volume
142 | -------------------------------------------------------------------------------- */
143 | .ajs-volume-control { cursor: pointer !important; }
144 | .ajs-volume-control div { display: block; margin: 0 5px 0 5px; padding: 4px 0 0 0; }
145 | /* Drawing the volume icon using 6 span elements */
146 | .ajs-volume-control div span { /* Individual volume bars */
147 | float: left; padding: 0;
148 | margin: 0 2px 0 0; /* Space between */
149 | width: 5px; height: 0px; /* Total height is height + bottom border */
150 | border-bottom: 18px solid #555; /* Default (off) color and height of visible portion */
151 | }
152 | .ajs-volume-control div span.ajs-volume-level-on { border-color: #fff; /* Volume on bar color */ }
153 | /* Creating differnt bar heights through height (transparent) and bottom border (visible). */
154 | .ajs-volume-control div span:nth-child(1) { border-bottom-width: 2px; height: 16px; }
155 | .ajs-volume-control div span:nth-child(2) { border-bottom-width: 4px; height: 14px; }
156 | .ajs-volume-control div span:nth-child(3) { border-bottom-width: 7px; height: 11px; }
157 | .ajs-volume-control div span:nth-child(4) { border-bottom-width: 10px; height: 8px; }
158 | .ajs-volume-control div span:nth-child(5) { border-bottom-width: 14px; height: 4px; }
159 | .ajs-volume-control div span:nth-child(6) { margin-right: 0; }
160 |
161 | /* Download Links - Used for browsers that don't support any audio.
162 | ---------------------------------------------------------*/
163 | .ajs-no-audio { font-size: small; line-height: 1.5; }
164 |
165 | /* Big Play Button (at start)
166 | ---------------------------------------------------------*/
167 | div.ajs-big-play-button {
168 | display: none; /* Start hidden */ z-index: 2;
169 | position: absolute; top: 50%; left: 50%; width: 80px; height: 80px; margin: -43px 0 0 -43px; text-align: center; vertical-align: center; cursor: pointer !important;
170 | border: 3px solid #fff; opacity: 0.9;
171 | -webkit-border-radius: 20px; border-radius: 20px;
172 |
173 | /* CSS Background Gradients */
174 | background-color: #0B151A;
175 | background: #1F3744 -webkit-gradient(linear, left top, left bottom, from(#0B151A), to(#1F3744)) left 40px;
176 | background: #1F3744 -moz-linear-gradient(top, #0B151A, #1F3744) left 40px;
177 |
178 | /* CSS Shadows */
179 | -webkit-box-shadow: 4px 4px 8px #000;
180 | box-shadow: 4px 4px 8px #000;
181 | }
182 | div.ajs-big-play-button:hover {
183 | -webkit-box-shadow: 0px 0px 80px #fff;
184 | box-shadow: 0px 0px 80px #fff;
185 | }
186 |
187 | div.ajs-big-play-button span {
188 | display: block; font-size: 0; line-height: 0;
189 | width: 0; height: 0; margin: 20px 0 0 23px;
190 | /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
191 | border-left: 40px solid #fff; /* Width & Color of play icon */
192 | /* Height of play icon is total top & bottom border widths. Color is transparent. */
193 | border-top: 20px solid rgba(0,0,0,0); border-bottom: 20px solid rgba(0,0,0,0);
194 | }
195 |
196 | /* Spinner Styles
197 | ---------------------------------------------------------*/
198 | /* CSS Spinners by Kilian Valkhof - http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/ */
199 | .ajs-spinner { display: none; position: absolute; top: 50%; left: 50%; width: 100px; height: 100px; z-index: 1; margin: -50px 0 0 -50px;
200 | /* Scaling makes the circles look smoother. */
201 | -webkit-transform:scale(0.5); -moz-transform:scale(0.5); transform: scale(0.5);
202 | }
203 | /* Spinner circles */
204 | .ajs-spinner div { position:absolute; left: 40px; top: 40px; width: 20px; height: 20px; background: #fff;
205 | -webkit-border-radius: 20px; border-radius: 20px;
206 | border: 1px solid #ccc; /* Added border so can be visible on white backgrounds */
207 | }
208 | /* Each circle */
209 | .ajs-spinner div:nth-child(1) { opacity: 0.12; -webkit-transform: rotate(000deg) translate(0, -40px) scale(0.1); -moz-transform: rotate(000deg) translate(0, -40px) scale(0.1); transform: rotate(000deg) translate(0, -40px) scale(0.1); }
210 | .ajs-spinner div:nth-child(2) { opacity: 0.25; -webkit-transform: rotate(045deg) translate(0, -40px) scale(0.2); -moz-transform: rotate(045deg) translate(0, -40px) scale(0.2); transform: rotate(045deg) translate(0, -40px) scale(0.2); }
211 | .ajs-spinner div:nth-child(3) { opacity: 0.37; -webkit-transform: rotate(090deg) translate(0, -40px) scale(0.4); -moz-transform: rotate(090deg) translate(0, -40px) scale(0.4); transform: rotate(090deg) translate(0, -40px) scale(0.4); }
212 | .ajs-spinner div:nth-child(4) { opacity: 0.50; -webkit-transform: rotate(135deg) translate(0, -40px) scale(0.6); -moz-transform: rotate(135deg) translate(0, -40px) scale(0.6); transform: rotate(135deg) translate(0, -40px) scale(0.6); }
213 | .ajs-spinner div:nth-child(5) { opacity: 0.62; -webkit-transform: rotate(180deg) translate(0, -40px) scale(0.8); -moz-transform: rotate(180deg) translate(0, -40px) scale(0.8); transform: rotate(180deg) translate(0, -40px) scale(0.8); }
214 | .ajs-spinner div:nth-child(6) { opacity: 0.75; -webkit-transform: rotate(225deg) translate(0, -40px) scale(1.0); -moz-transform: rotate(225deg) translate(0, -40px) scale(1.0); transform: rotate(225deg) translate(0, -40px) scale(1.0); }
215 | .ajs-spinner div:nth-child(7) { opacity: 0.87; -webkit-transform: rotate(270deg) translate(0, -40px) scale(1.1); -moz-transform: rotate(270deg) translate(0, -40px) scale(1.1); transform: rotate(270deg) translate(0, -40px) scale(1.1); }
216 | .ajs-spinner div:nth-child(8) { opacity: 1.00; -webkit-transform: rotate(315deg) translate(0, -40px) scale(1.3); -moz-transform: rotate(315deg) translate(0, -40px) scale(1.3); transform: rotate(315deg) translate(0, -40px) scale(1.3); }
--------------------------------------------------------------------------------
/audio.js:
--------------------------------------------------------------------------------
1 | /*
2 | AudioJS - HTML5 Audio Player
3 | v2.0.2
4 |
5 | This file is part of VideoJS. Copyright 2010 Zencoder, Inc.
6 | -Modified for html5 audio tag by dz0ny
7 | -Updated to newer VideoJS version (2.0.2) by dodo
8 |
9 | Based on VideoJS 6824c1f1d8bcc3f5b45c
10 |
11 | AudioJS is free software: you can redistribute it and/or modify
12 | it under the terms of the GNU Lesser General Public License as published by
13 | the Free Software Foundation, either version 3 of the License, or
14 | (at your option) any later version.
15 |
16 | AudioJS is distributed in the hope that it will be useful,
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | GNU Lesser General Public License for more details.
20 |
21 | You should have received a copy of the GNU Lesser General Public License
22 | along with AudioJS. If not, see .
23 | */
24 |
25 | // Self-executing function to prevent global vars and help with minification
26 | (function(window, undefined){
27 | var document = window.document;
28 |
29 | // Using jresig's Class implementation http://ejohn.org/blog/simple-javascript-inheritance/
30 | (function(){var initializing=false, fnTest=/xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; this.JRClass = function(){}; JRClass.extend = function(prop) { var _super = this.prototype; initializing = true; var prototype = new this(); initializing = false; for (var name in prop) { prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn){ return function() { var tmp = this._super; this._super = _super[name]; var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } function JRClass() { if ( !initializing && this.init ) this.init.apply(this, arguments); } JRClass.prototype = prototype; JRClass.constructor = JRClass; JRClass.extend = arguments.callee; return JRClass;};})();
31 |
32 | // Audio JS Player Class
33 | var AudioJS = JRClass.extend({
34 |
35 | // Initialize the player for the supplied audio tag element
36 | // element: audio tag
37 | init: function(element, setOptions){
38 |
39 | // Allow an ID string or an element
40 | if (typeof element == 'string') {
41 | this.audio = document.getElementById(element);
42 | } else {
43 | this.audio = element;
44 | }
45 | // Store reference to player on the audio element.
46 | // So you can acess the player later: document.getElementById("audio_id").player.play();
47 | this.audio.player = this;
48 | this.values = {}; // Cache audio values.
49 | this.elements = {}; // Store refs to controls elements.
50 |
51 | // Default Options
52 | this.options = {
53 | autoplay: false,
54 | preload: true,
55 | useBuiltInControls: false, // Use the browser's controls (iPhone)
56 | controlsAtStart: true, // Make controls visible when page loads
57 | controlsHiding: false, // Hide controls when not over the audio
58 | defaultVolume: 0.85, // Will be overridden by localStorage volume if available
59 | volumeBars: 6,
60 | playerFallbackOrder: ["html5", "links"] // Players and order to use them
61 | };
62 | // Override default options with global options
63 | if (typeof AudioJS.options == "object") { AudioJS.merge(this.options, AudioJS.options); }
64 | // Override default & global options with options specific to this player
65 | if (typeof setOptions == "object") { AudioJS.merge(this.options, setOptions); }
66 | // Override preload & autoplay with audio attributes
67 | if (this.getPreloadAttribute() !== undefined) { this.options.preload = this.getPreloadAttribute(); }
68 | if (this.getAutoplayAttribute() !== undefined) { this.options.autoplay = this.getAutoplayAttribute(); }
69 |
70 | // Store reference to embed code pieces
71 | this.box = this.audio.parentNode;
72 | this.linksFallback = this.getLinksFallback();
73 | this.hideLinksFallback(); // Will be shown again if "links" player is used
74 |
75 | // Loop through the player names list in options, "html5" etc.
76 | // For each player name, initialize the player with that name under AudioJS.players
77 | // If the player successfully initializes, we're done
78 | // If not, try the next player in the list
79 | this.each(this.options.playerFallbackOrder, function(playerType){
80 | if (this[playerType+"Supported"]()) { // Check if player type is supported
81 | this[playerType+"Init"](); // Initialize player type
82 | return true; // Stop looping though players
83 | }
84 | });
85 |
86 | // Start Global Listeners - API doesn't exist before now
87 | this.activateElement(this, "player");
88 | this.activateElement(this.box, "box");
89 | },
90 | /* Behaviors
91 | ================ */
92 | behaviors: {},
93 | newBehavior: function(name, activate, functions){
94 | this.behaviors[name] = activate;
95 | this.extend(functions);
96 | },
97 | activateElement: function(element, behavior){
98 | // Allow passing and ID string
99 | if (typeof element == "string") { element = document.getElementById(element); }
100 | this.behaviors[behavior].call(this, element);
101 | },
102 | /* Errors/Warnings
103 | ================ */
104 | errors: [], // Array to track errors
105 | warnings: [],
106 | warning: function(warning){
107 | this.warnings.push(warning);
108 | this.log(warning);
109 | },
110 | /* History of errors/events (not quite there yet)
111 | ================ */
112 | history: [],
113 | log: function(event){
114 | if (!event) { return; }
115 | if (typeof event == "string") { event = { type: event }; }
116 | if (event.type) { this.history.push(event.type); }
117 | if (this.history.length >= 50) { this.history.shift(); }
118 | try { console.log(event.type); } catch(e) { try { opera.postError(event.type); } catch(e){} }
119 | },
120 | /* Local Storage
121 | ================ */
122 | setLocalStorage: function(key, value){
123 | if (!localStorage) { return; }
124 | try {
125 | localStorage[key] = value;
126 | } catch(e) {
127 | if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014
128 | this.warning(AudioJS.warnings.localStorageFull);
129 | }
130 | }
131 | },
132 | /* Helpers
133 | ================ */
134 | getPreloadAttribute: function(){
135 | if (typeof this.audio.hasAttribute == "function" && this.audio.hasAttribute("preload")) {
136 | var preload = this.audio.getAttribute("preload");
137 | // Only included the attribute, thinking it was boolean
138 | if (preload === "" || preload === "true") { return "auto"; }
139 | if (preload === "false") { return "none"; }
140 | return preload;
141 | }
142 | },
143 | getAutoplayAttribute: function(){
144 | if (typeof this.audio.hasAttribute == "function" && this.audio.hasAttribute("autoplay")) {
145 | var autoplay = this.audio.getAttribute("autoplay");
146 | if (autoplay === "false") { return false; }
147 | return true;
148 | }
149 | },
150 | // Calculates amoutn of buffer is full
151 | bufferedPercent: function(){ return (this.duration()) ? this.buffered()[1] / this.duration() : 0; },
152 | // Each that maintains player as context
153 | // Break if true is returned
154 | each: function(arr, fn){
155 | if (!arr || arr.length === 0) { return; }
156 | for (var i=0,j=arr.length; i 0) {
409 | var newBufferEnd = (event.loaded / event.total) * this.duration();
410 | if (newBufferEnd > this.values.bufferEnd) { this.values.bufferEnd = newBufferEnd; }
411 | }
412 | },
413 |
414 | iOSInterface: function(){
415 | if(AudioJS.iOSVersion() < 4) { this.forceTheSource(); } // Fix loading issues
416 | if(AudioJS.isIPad()) {
417 | this.buildAndActivateSpinner(); // Spinner still works well on iPad, since iPad doesn't have one
418 | }
419 | },
420 |
421 | // Fix android specific quirks
422 | // Use built-in controls, but add the big play button, since android doesn't have one.
423 | androidInterface: function(){
424 | this.forceTheSource(); // Fix loading issues
425 | _A_.addListener(this.audio, "click", function(){ this.play(); }); // Required to play
426 | },
427 | /* Wait for styles (TODO: move to _A_)
428 | ================ */
429 | loadInterface: function(){
430 | if (this.options.controlsAtStart) { this.showControlBars(); }
431 | this.positionControlBars();
432 | },
433 | /* Control Bar
434 | ================
435 |
436 | Builds this markup:
437 |
438 |