/* ECMA-262 Add Array indexOf() if no native browser support https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf */ if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { "use strict"; if (this == null) { throw new TypeError(); } var t = Object(this); var len = t.length >>> 0; if (len === 0) { return -1; } var n = 0; if (arguments.length > 0) { n = Number(arguments[1]); if (n != n) { // shortcut for verifying if it's NaN n = 0; } else if (n != 0 && n != Infinity && n != -Infinity) { n = (n > 0 || -1) * Math.floor(Math.abs(n)); } } if (n >= len) { return -1; } var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); for (; k < len; k++) { if (k in t && t[k] === searchElement) { return k; } } return -1; } } /* name: sp-player-tumblr $Rev: 33729 $ $Date: 2008-12-08 17:29:22 -0500 (Mon, 08 Dec 2008) $ author: Dan Kantor JDUThemes Tumblr Streampad Player v2 http://jduthemes.tumblr.com 21 Mar 2013 */ streampadPlayerBlogV2 = { start: 0, num: SPenableshuffle === "true" || SPshowplaylistbutton === "true" ? 50 : 20, total: 0, isHandleMore: false, fireHandleMore: false, oldArray: 0, shuffle: SPenableshuffle === "true" ? true : false, randomQueueNumber: 0, isMuted: false, volume: 0, init: function() { streampadPlayer.Event.remove(window, "init", streampadPlayerBlogV2.init); streampadPlayer.Event.add(window, "getTotal", streampadPlayerBlogV2.getTotal); streampadPlayer.vars.playlistType = "tumblr"; if (streampadPlayer.params.api === null) { streampadPlayerBlogV2.playlistParam = location.hostname; } else { streampadPlayerBlogV2.playlistParam = streampadPlayer.params.api; } if (streampadPlayerBlogV2.shuffle === true) { streampadPlayer.Events.nextTrack = function() { if (streampadPlayer.vars.total > 0) { do { streampadPlayerBlogV2.randomQueueNumber = Math.floor(Math.random() * streampadPlayer.Playlist.array.length); } while (streampadPlayer.vars.queueNumber === streampadPlayerBlogV2.randomQueueNumber && streampadPlayer.vars.total !== 1); streampadPlayer.vars.queueNumber = streampadPlayerBlogV2.randomQueueNumber; } streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); }; streampadPlayer.Events.previousTrack = function() { if (streampadPlayer.vars.total > 0) { do { streampadPlayerBlogV2.randomQueueNumber = Math.floor(Math.random() * streampadPlayer.Playlist.array.length); } while (streampadPlayer.vars.queueNumber === streampadPlayerBlogV2.randomQueueNumber && streampadPlayer.vars.total !== 1); streampadPlayer.vars.queueNumber = streampadPlayerBlogV2.randomQueueNumber; } streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); }; } }, getAudio: function() { streampadPlayer.UI.setCaption("Loading Audio Posts..."); streampadPlayer.Utils.scriptRequest("http://" + streampadPlayerBlogV2.playlistParam + "/api/read/json?callback=streampadPlayerBlogV2.getAudioResponse&type=audio&start=" + streampadPlayerBlogV2.start + "&num=" + streampadPlayerBlogV2.num); }, getAudioResponse: function(c) { streampadPlayer.Event.fire(window, 'getTotal', c["posts-total"]); for (i = 0; i < c.posts.length; i++) { var m = c.posts[i]; var k = m["audio-player"]; var j = k.indexOf("assets.tumblr.com") + decodeURIComponent(k).indexOf("api.soundcloud.com/tracks"); if (SPplaysongstagged) { if (c.posts[i]["tags"]) { var l = c.posts[i]["tags"].indexOf(SPplaysongstagged); if (l === -1) { j = -2; } } else { j = -2; } } if (SPdontplaysongstagged) { if (c.posts[i]["tags"]) { var l = c.posts[i]["tags"].indexOf(SPdontplaysongstagged); if (l !== -1) { j = -2; } else if (l === -1) { j = 0; } } } if (j === -2) { var t = c.posts.splice(i, 1); streampadPlayer.vars.total = streampadPlayer.vars.total - t.length; i--; } } if (c.posts.length > 0) { for (i = 0; i < c.posts.length; i++) { if (c.posts[i]["audio-player"].indexOf("assets.tumblr.com") != -1) { var e = c.posts[i]["audio-player"].split("audio_file="); var b = e[1].split("&color="); var d = b[0] + "?plead=please-dont-download-this-or-our-lawyers-wont-let-us-host-audio"; } else if (c.posts[i]["audio-player"].indexOf("api.soundcloud.com") != -1) { var e = decodeURIComponent(c.posts[i]["audio-player"]).split("api.soundcloud.com"); var b = e[1].match(/[0-9]+/g); var d = "https://api.soundcloud.com/tracks/" + b[0] + "/stream?client_id=3cQaPshpEeLqMsNFAUw1Q"; } else { streampadPlayer.vars.total--; continue; } var a = new streampadPlayer.SongVO(); a.id3artist = c.posts[i]["id3-artist"]; a.id3title = c.posts[i]["id3-title"]; if (SPenableid3audiocaptions === "true") { if (a.id3artist === undefined && a.id3title === undefined) { a.text = c.posts[i]["audio-caption"].replace(/(<([^>]+)>)/ig, ""); } else { if (a.id3artist === undefined && a.id3title !== undefined) { a.text = "Unknown Artist - " + a.id3title; } else { if (a.id3artist !== undefined && a.id3title === undefined) { a.text = a.id3artist + " - Unknown Track Title"; } else { a.text = a.id3artist + " - " + a.id3title; } } } } else { a.text = c.posts[i]["audio-caption"].replace(/(<([^>]+)>)/ig, ""); } a.description = c.posts[i]["audio-caption"]; a.enclosure = decodeURIComponent(d); a.sourceUrl = c.posts[i]["url"]; a.plays = c.posts[i]["audio-plays"]; streampadPlayer.Playlist.push(a); } streampadPlayer.Playlist.title = c.tumblelog.title; streampadPlayerBlogV2.start = streampadPlayerBlogV2.start + streampadPlayerBlogV2.num; if (streampadPlayerBlogV2.shuffle === true) { if (streampadPlayerBlogV2.start < streampadPlayerBlogV2.total) { streampadPlayerBlogV2.getAudio(); } else { streampadPlayer.vars.queueNumber = -1; streampadPlayer.Events.nextTrack(); } } else if (streampadPlayer.params.showplaylistbutton === 'true') { if (streampadPlayerBlogV2.start < streampadPlayerBlogV2.total) { streampadPlayerBlogV2.getAudio(); } else { streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } } else if (streampadPlayer.vars.isPlaying === undefined && streampadPlayer.Event.listeners['click' + document.getElementById('streampadPlayTrack')]) { streampadPlayer.Event.add(document.getElementById('streampadPlayTrack'), 'click', streampadPlayer.Events.playTrack); streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } else if (streampadPlayer.vars.isPlaying === false && streampadPlayer.vars.queueNumber === 0) { streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } } else if (streampadPlayerBlogV2.total > 0 && streampadPlayerBlogV2.start < streampadPlayerBlogV2.total - 1 && streampadPlayer.vars.queueNumber !== undefined) { streampadPlayerBlogV2.start = streampadPlayerBlogV2.start + streampadPlayerBlogV2.num; streampadPlayerBlogV2.getAudio(); } else if (streampadPlayer.vars.total === 0) { streampadPlayer.UI.noAudioPosts(); } else if (streampadPlayer.vars.queueNumber === undefined) { if (streampadPlayerBlogV2.oldArray === streampadPlayer.vars.total && streampadPlayerBlogV2.isHandleMore === true) { streampadPlayerBlogV2.fireHandleMore = true; } streampadPlayerBlogV2.start = streampadPlayerBlogV2.start + streampadPlayerBlogV2.num; } else if (streampadPlayerBlogV2.shuffle === true) { streampadPlayer.vars.queueNumber = -1; streampadPlayer.Events.nextTrack(); } else { streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } streampadPlayer.Event.fire(window, 'gotPlaylist', c); streampadPlayer.Event.fire(window, 'skipCallback', streampadPlayer.Playlist.array.length); }, handleMore: function() { if (streampadPlayer.vars.queueNumber < streampadPlayer.vars.total - 1 && streampadPlayer.vars.queueNumber <= streampadPlayer.Playlist.array.length - 1) { streampadPlayerBlogV2.isHandleMore = true; SPAPI.skip(streampadPlayer.vars.queueNumber + 1); } else if (streampadPlayer.vars.queueNumber === streampadPlayer.vars.total - 1) { streampadPlayer.vars.queueNumber = 0; streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } }, handleLess: function() { SPAPI.skip(streampadPlayer.vars.total - 1); }, getTotal: function(total) { streampadPlayer.Event.remove(window, "getTotal", streampadPlayerBlogV2.getTotal); streampadPlayerBlogV2.total = total; streampadPlayer.vars.total = total; }, volumeMuteBuild: function() { var volumeMute = document.createElement('div'); volumeMute.setAttribute('id', 'volumeMute'); streampadPlayer.Utils.setStyles(volumeMute, {'cssFloat' : 'right', 'styleFloat' : 'right', 'width' : '0px', 'height' : '30px', 'cursor' : 'pointer', 'position' : 'relative'}); document.getElementById('streampadVolumeButton').parentNode.insertBefore(volumeMute, document.getElementById('streampadVolumeButton')); streampadPlayer.Event.add(volumeMute, 'mouseover', streampadPlayer.Events.volumeButtonMouseOver); streampadPlayer.Event.add(volumeMute, 'mouseout', streampadPlayer.Events.volumeButtonMouseOut); streampadPlayer.Event.add(volumeMute, 'click', streampadPlayerBlogV2.volumeMuteToggle); streampadPlayer.Event.add(document.getElementById('streampadVolumeButton'), 'click', streampadPlayerBlogV2.volumeMuteToggle); streampadPlayerBlogV2.isMuted = (streampadPlayer.vars.theVolume === 0) ? true : false; if (streampadPlayerBlogV2.isMuted === true) { streampadPlayer.Utils.setStyles(document.getElementById('streampadVolumeButton'), {'width' : '16px'}); streampadPlayer.Utils.setStyles(document.getElementById('volumeMute'), {'width' : '12px'}); } else if (streampadPlayerBlogV2.isMuted === false) { streampadPlayer.Utils.setStyles(document.getElementById('streampadVolumeButton'), {'width' : '28px'}); streampadPlayer.Utils.setStyles(document.getElementById('volumeMute'), {'width' : '0px'}); } streampadPlayer.Events.volumeDragDown = function (e) { streampadPlayer.Event.add(document, 'mousemove', streampadPlayer.Events.volumeDragMove); streampadPlayer.Event.add(document, 'mouseup', streampadPlayer.Events.volumeDragUp); streampadPlayer.Event.add(document, 'mousemove', streampadPlayerBlogV2.volumeDragDownMouseMoveEventIntercept); if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } } streampadPlayer.Events.volumeDragUp = function (e) { streampadPlayer.Event.remove(document, 'mousemove', streampadPlayer.Events.volumeDragMove); streampadPlayer.Event.remove(document, 'mouseup', streampadPlayer.Events.volumeDragUp); streampadPlayer.Event.remove(document, 'mousemove', streampadPlayerBlogV2.volumeDragDownMouseMoveEventIntercept); } }, volumeDragDownMouseMoveEventIntercept: function() { streampadPlayer.Utils.setStyles(document.getElementById('streampadVolumeButton'), {'width' : '28px'}); streampadPlayer.Utils.setStyles(document.getElementById('volumeMute'), {'width' : '0px'}); streampadPlayerBlogV2.isMuted = false; if (streampadPlayer.vars.theVolume === 0) { streampadPlayer.Utils.setStyles(document.getElementById('streampadVolumeButton'), {'width' : '16px'}); streampadPlayer.Utils.setStyles(document.getElementById('volumeMute'), {'width' : '12px'}); streampadPlayerBlogV2.volume = streampadPlayer.vars.theVolume; streampadPlayerBlogV2.isMuted = true; } }, volumeMuteToggle: function() { (streampadPlayerBlogV2.isMuted === false) ? streampadPlayerBlogV2.volumeMute() : streampadPlayerBlogV2.volumeUnMute(); }, volumeMute: function() { streampadPlayer.Utils.setStyles(document.getElementById('streampadVolumeButton'), {'width' : '16px'}); streampadPlayer.Utils.setStyles(document.getElementById('volumeMute'), {'width' : '12px'}); streampadPlayerBlogV2.volume = streampadPlayer.vars.theVolume; streampadPlayer.vars.theVolume = 0; streampadPlayer.flash.getSWF("streampadFlash").setVolume(0); streampadPlayerBlogV2.isMuted = true; }, volumeUnMute: function() { streampadPlayer.Utils.setStyles(document.getElementById('streampadVolumeButton'), {'width' : '28px'}); streampadPlayer.Utils.setStyles(document.getElementById('volumeMute'), {'width' : '0px'}); streampadPlayer.vars.theVolume = streampadPlayerBlogV2.volume; streampadPlayer.flash.getSWF("streampadFlash").setVolume(streampadPlayer.vars.theVolume/100); streampadPlayerBlogV2.isMuted = false; }, setVolume: function() { streampadPlayer.vars.theVolume = 91; streampadPlayer.flash.getSWF("streampadFlash").setVolume(streampadPlayer.vars.theVolume/100); } }; streampadPlayer.Event.add(window, "init", streampadPlayerBlogV2.init); streampadPlayer.Event.add(window, "flashLoaded", streampadPlayerBlogV2.getAudio); streampadPlayer.Event.add(window, "handleMore", streampadPlayerBlogV2.handleMore); streampadPlayer.Event.add(window, "handleLess", streampadPlayerBlogV2.handleLess); if (SPshowvolumebutton === "true") { streampadPlayer.Event.add(window, "flashLoaded", streampadPlayerBlogV2.volumeMuteBuild); } else { streampadPlayer.Event.add(window, "flashLoaded", streampadPlayerBlogV2.setVolume); } SPAPI.skip = function(n) { if (n <= 0) { n = 0; } if (n > streampadPlayer.vars.total - 1) { n = streampadPlayer.vars.total - 1; } if (n > streampadPlayer.Playlist.array.length - 1 && streampadPlayer.vars.queueNumber >= 0) { skipCallback = function(arrayLength) { if (n > streampadPlayer.vars.total - 1) { n = streampadPlayer.vars.total - 1; } if (n > arrayLength - 1) { streampadPlayerBlogV2.getAudio(); } else if (n <= arrayLength - 1) { streampadPlayer.Event.remove(window, 'skipCallback', skipCallback); streampadPlayer.Event.add(document.getElementById('streampadPlayTrack'), 'click', streampadPlayer.Events.playTrack); streampadPlayer.vars.queueNumber = n; if (streampadPlayerBlogV2.fireHandleMore === true) { streampadPlayerBlogV2.isHandleMore = false; streampadPlayerBlogV2.fireHandleMore = false; streampadPlayerBlogV2.handleMore(); } else { streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } } }; streampadPlayerBlogV2.oldArray = streampadPlayer.Playlist.array.length; streampadPlayer.vars.queueNumber = undefined; streampadPlayer.Event.remove(document.getElementById('streampadPlayTrack'), 'click', streampadPlayer.Events.playTrack); streampadPlayer.Event.add(window, 'skipCallback', skipCallback); streampadPlayerBlogV2.getAudio(); } else if (streampadPlayer.vars.queueNumber >= 0) { streampadPlayer.vars.queueNumber = n; streampadPlayer.Play.queueNumber(streampadPlayer.vars.queueNumber); } }; streampadPlayer.params.bgcolor = SPbgcolor; streampadPlayer.params.bgcolor = streampadPlayer.params.bgcolor.replace(/^#+/, ""); streampadPlayer.params.trackcolor = SPtrackcolor; streampadPlayer.params.trackcolor = streampadPlayer.params.trackcolor.replace(/^#+/, ""); if (streampadPlayer.params.trackcolor === "") { streampadPlayer.params.trackcolor = 'FFFFFF'; } streampadPlayer.params.clicktext = SPclicktext; streampadPlayer.params.clickimg = SPclickimg; streampadPlayer.params.autoplay = SPautoplay; streampadPlayer.params.showpop = SPshowpop; streampadPlayer.params.progressfrontcolor = SPprogressfrontcolor; streampadPlayer.params.progressfrontcolor = streampadPlayer.params.progressfrontcolor.replace(/^#+/, ""); if (streampadPlayer.params.progressfrontcolor === "") { streampadPlayer.params.progressfrontcolor = 'FFFFFF'; } streampadPlayer.params.progressbackcolor = SPprogressbackcolor; streampadPlayer.params.progressbackcolor = streampadPlayer.params.progressbackcolor.replace(/^#+/, ""); if (streampadPlayer.params.progressbackcolor === "") { streampadPlayer.params.progressbackcolor = 'CCCCCC'; } streampadPlayer.params.showplaylistbutton = SPshowplaylistbutton; streampadPlayer.params.showplaylist = SPshowplaylist; if (streampadPlayer.params.showplaylistbutton == 'false') { streampadPlayer.params.showplaylist = 'false'; } streampadPlayer.params.drawersize = SPdrawersize streampadPlayer.params.drawersize = streampadPlayer.params.drawersize.replace(/(px)+$/, ""); if (streampadPlayer.params.drawersize === "") { streampadPlayer.params.drawersize = '215'; } streampadPlayer.params.showvolumebutton = SPshowvolumebutton; streampadPlayer.params.btncolor = SPbtncolor; if (streampadPlayer.params.btncolor === "" || streampadPlayer.params.btncolor === 'white-gray OR white-black OR black-gray OR black-white OR blue-white') { streampadPlayer.params.btncolor = 'white-gray'; } streampadPlayer.params.api = SPapi; streampadPlayer.params.api = streampadPlayer.params.api.replace(/.*?:\/\//g, ""); streampadPlayer.params.api = streampadPlayer.params.api.replace(/^www\./i, ""); streampadPlayer.params.api = streampadPlayer.params.api.replace(/\/$/, ""); if (streampadPlayer.params.api === "") { streampadPlayer.params.api = null; } /* JDUThemes Tumblr Streampad Player v2 CSS dynamic insertion http://jduthemes.tumblr.com 01 Feb 2013 */ (function () { var cssCode = '#streampadBottomBar,#streampadBottomBar > div{color:'+SPtrackcolor+'!important}' cssCode += SPshowplayscounter != 'true' ? '#streampadAudioPlays{display:none}' : ''; cssCode += SPshowprofilebutton != 'true' ? '#streampadProfileButton{display:none}' : ''; cssCode += SPshowfullscreenbutton != 'true' ? '#streampadPlayerFullScreenButton{display:none}' : ''; cssCode += SPenabletransparency === 'true' ? '#streampadBottomBar{background:transparent!important}#streampadVolDiv{background-color:transparent!important}' : ''; cssCode += SPenabletransparency === 'true' || (SPshowpop === 'false' && SPshowprofilebutton === 'false' && SPshowfullscreenbutton === 'false' && SPshowplaylistbutton === 'false' && SPshowvolumebutton === 'false') ? '#streampadPlayerBorderNum1,#streampadPlayerBorderNum2,#streampadPlayerBorderNum3,#streampadPlayerBorderNum4,#streampadPlayerBorderNum5,#streampadPlayerBorderNum6{display:none}' : ''; var styleElement = document.createElement("style"); styleElement.type = "text/css"; if (styleElement.styleSheet) { styleElement.styleSheet.cssText = cssCode; } else { styleElement.appendChild(document.createTextNode(cssCode)); } document.getElementsByTagName("head")[0].appendChild(styleElement); })();