Skip to content

Commit

Permalink
Merge branch 'V2.97a.20130512+DEV'
Browse files Browse the repository at this point in the history
  • Loading branch information
scottschiller committed Nov 9, 2013
2 parents fc6ef46 + 7a33be2 commit 7ddf289
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 231 deletions.
33 changes: 24 additions & 9 deletions demo/360-player/script/360player.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ function ThreeSixtyPlayer() {
}

var o = self.getTheDamnLink(e),
sURL, soundURL, thisSound, oContainer, has_vis, diameter;
canvasElements, sURL, soundURL, thisSound, oContainer, has_vis, diameter;

if (o.nodeName.toLowerCase() !== 'a') {
o = self.isChildOfNode(o,'a');
Expand Down Expand Up @@ -465,12 +465,15 @@ function ThreeSixtyPlayer() {

diameter = parseInt(self.getElementsByClassName('sm2-360ui','div',oContainer)[0].offsetWidth, 10);

// see note re: IE <9 and excanvas when Modernizr is included, making weird things happen with <canvas>.
canvasElements = self.getElementsByClassName('sm2-canvas','canvas',oContainer),

thisSound._360data = {
oUI360: self.getParentByClassName(o,'ui360'), // the (whole) entire container
oLink: o, // DOM node for reference within SM2 object event handlers
className: self.css.sPlaying,
oUIBox: self.getElementsByClassName('sm2-360ui','div',oContainer)[0],
oCanvas: self.getElementsByClassName('sm2-canvas','canvas',oContainer)[0],
oCanvas: canvasElements[canvasElements.length-1],
oButton: self.getElementsByClassName('sm2-360btn','span',oContainer)[0],
oTiming: self.getElementsByClassName('sm2-timing','div',oContainer)[0],
oCover: self.getElementsByClassName('sm2-cover','div',oContainer)[0],
Expand Down Expand Up @@ -729,7 +732,7 @@ function ThreeSixtyPlayer() {
canvas = oCanvas,
ctx, innerRadius, doesntLikeZero, endPoint;

if (canvas.getContext){
if (canvas.getContext) {
// use getContext to use the canvas for drawing
ctx = canvas.getContext('2d');
}
Expand Down Expand Up @@ -799,13 +802,17 @@ function ThreeSixtyPlayer() {
var canvas = oCanvas,
ctx = null,
width, height;
if (canvas.getContext){

if (canvas.getContext) {
// use getContext to use the canvas for drawing
ctx = canvas.getContext('2d');
}
width = canvas.offsetWidth;
height = canvas.offsetHeight;
ctx.clearRect(-(width/2), -(height/2), width, height);

if (ctx) {
width = canvas.offsetWidth;
height = canvas.offsetHeight;
ctx.clearRect(-(width/2), -(height/2), width, height);
}

};

Expand Down Expand Up @@ -1018,7 +1025,7 @@ function ThreeSixtyPlayer() {
sm._writeDebug('threeSixtyPlayer.init()');

var oItems = self.getElementsByClassName('ui360','div'),
i, j, oLinks = [], is_vis = false, foundItems = 0, oCanvas, oCanvasCTX, oCover, diameter, radius, uiData, uiDataVis, oUI, oBtn, o, o2, oID;
i, j, oLinks = [], is_vis = false, foundItems = 0, canvasElements, oCanvas, oCanvasCTX, oCover, diameter, radius, uiData, uiDataVis, oUI, oBtn, o, o2, oID;

for (i=0,j=oItems.length; i<j; i++) {
oLinks.push(oItems[i].getElementsByTagName('a')[0]);
Expand Down Expand Up @@ -1067,13 +1074,21 @@ function ThreeSixtyPlayer() {
o = oLinks[i].parentNode;
o2 = document.createElement('canvas');
o2.className = 'sm2-canvas';
oID = 'sm2_canvas_'+parseInt(Math.random()*1048576, 10);
oID = 'sm2_canvas_'+i+(new Date().getTime());
o2.id = oID;
o2.width = diameter;
o2.height = diameter;
oUI.appendChild(o2);
window.G_vmlCanvasManager.initElement(o2); // Apply ExCanvas compatibility magic
oCanvas = document.getElementById(oID);
/**
* 05/2013: If present, Modernizr results in two canvas elements or something being made, one being <:canvas>.
* When this is the case, the first doesn't have getContext('2d') and such - so, use the second.
*/
canvasElements = oCanvas.parentNode.getElementsByTagName('canvas');
if (canvasElements.length > 1) {
oCanvas = canvasElements[canvasElements.length-1];
}
} else {
// add a handler for the button
oCanvas = oLinks[i].parentNode.getElementsByTagName('canvas')[0];
Expand Down
13 changes: 8 additions & 5 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ <h3>soundManager Global Object</h3>
<dd>Example:
<pre class="block"><code><span><span>// link example: &lt;a id="song1" href="foo.php?songID=1" type="audio/mp3"&gt;play #1&lt;/a&gt;</span></span>
var aLink = document.getElementById('<span>song1</span>');
if (soundManager.canPlayLink(aLink)) {
soundManager.play('<span>song1Sound</span>', aLink.href);
if (soundManager.canPlayMIME(aLink.type)) {
soundManager.createSound('<span>song1Sound</span>', aLink.href);
}</code></pre></dd>
<dd>If no <code>type</code> attribute is found, this method will return <code>null</code> instead of <code>false</code>.</dd>
</dl>
Expand All @@ -838,7 +838,7 @@ <h3>soundManager Global Object</h3>
<dd>Example:
<pre class="block"><code>var sURL = '<span>/path/to/some.mp3</span>';
if (soundManager.canPlayURL(sURL)) {
soundManager.createSound('<span>fooSound</span>',sURL);
soundManager.createSound('<span>fooSound</span>', sURL);
}</code></pre></dd>
<dd>If no <code>href</code> attribute is found, this method will return <code>null</code> instead of <code>false</code>.</dd>
</dl>
Expand Down Expand Up @@ -1499,8 +1499,9 @@ <h3 id="soundmanager-sound-dynamic-properties">Sound Object Dynamic Properties</
<dt>durationEstimate</dt>
<dd>The estimated duration of the sound, specified in milliseconds.</dd>
<dd>Due to the dynamic nature of <code>duration</code> while loading, this attempts to provide the full duration by calculating <code>parseInt((self.bytesTotal/self.bytesLoaded)*self.duration)</code> and is updated with each <code>whileloading()</code> interval.</dd>
<dd>Once the sound has fully loaded, <code>duration</code> should be referenced as it will contain the final and accurate value.</dd>
<dd>Note that this method works only with Constant Bitrate (CBR)-encoded MP3s due to the consistent data/time assumption. VBR-encoded MP3s will give inaccurate results.</dd>
<dd>(Flash-only): Once the sound has fully loaded (<code>onload()</code> has fired), <code>durationEstimate</code> will be updated with the final, Flash-calculated value of <code>duration</code>.</dd>
<dd>Note that the <code>durationEstimate</code> method works only with Constant Bitrate (CBR)-encoded MP3s due to the consistent data/time assumption. VBR-encoded MP3s will give inaccurate results.</dd>
<dd>HTML5 behaviour: Both <code>duration</code> and <code>durationEstimate</code> are updated at regular intervals during loading of HTML5 audio, directly referencing the duration property provided on the native HTML5 object. Unlike Flash, HTML5 typically gets the true and final duration value by the time playback begins.</dd>
</dl>

<dl id="smsound-eqdata" class="f-block s-eqdata">
Expand Down Expand Up @@ -1597,6 +1598,8 @@ <h3 id="soundmanager-sound-dynamic-properties">Sound Object Dynamic Properties</
<dd>1 = loading</dd>
<dd>2 = failed/error</dd>
<dd>3 = loaded/success</dd>
<dd>Under Flash, <code>readyState</code> will move from 0 to 1, and then change to 3 when the sound's <code>onload()</code> event fires (and all bytes have loade.)</dd>
<dd>Under HTML5, <code>readyState</code> will move from 0 to 1 when initializing the HTTP request (from <code>load()</code>), and will quickly change to 3 when the sound is ready to play. Note that HTML5 is buffer-based and <code>onload()</code> means "enough audio data has buffered to begin playback".</dd>
</dl>

<dl id="smsound-type" class="f-block s-type">
Expand Down
Loading

0 comments on commit 7ddf289

Please sign in to comment.