From 9441defd90d08af64a088d640f4777e6db5f0b7a Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Fri, 26 Jul 2013 15:33:28 +0300 Subject: [PATCH] RSSAudioPlayer 1.0 Quick system to play your (currently my) favourite podcast feeds and stuff. --- .gitignore | 5 ++ .htaccess | 9 ++ assets/audiojs/LICENSE | 19 +++++ assets/audiojs/audio.min.js | 24 ++++++ assets/audiojs/audiojs.swf | Bin 0 -> 1644 bytes assets/audiojs/player-graphics.gif | Bin 0 -> 4499 bytes assets/scripts.js | 51 +++++++++++ assets/style.css | 66 ++++++++++++++ composer.json | 8 ++ feeds.json | 5 ++ inc/rss-audio-player.php | 133 +++++++++++++++++++++++++++++ index.php | 44 ++++++++++ templates/footer.php | 34 ++++++++ templates/header.php | 23 +++++ templates/list.php | 26 ++++++ templates/show.php | 48 +++++++++++ vendor/.gitkeep | 0 17 files changed, 495 insertions(+) create mode 100644 .gitignore create mode 100644 .htaccess create mode 100644 assets/audiojs/LICENSE create mode 100644 assets/audiojs/audio.min.js create mode 100644 assets/audiojs/audiojs.swf create mode 100644 assets/audiojs/player-graphics.gif create mode 100644 assets/scripts.js create mode 100644 assets/style.css create mode 100644 composer.json create mode 100644 feeds.json create mode 100644 inc/rss-audio-player.php create mode 100644 index.php create mode 100644 templates/footer.php create mode 100644 templates/header.php create mode 100644 templates/list.php create mode 100644 templates/show.php create mode 100644 vendor/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e201d28 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/vendor/* +!/vendor/.gitkeep +/cache/* +!/cache/.gitkeep +composer.lock \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..4b8c2df --- /dev/null +++ b/.htaccess @@ -0,0 +1,9 @@ + +RewriteEngine On +RewriteBase /rss-audio-player/ +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^([^/]*)$ ./index.php [QSA] +RewriteRule ^list/([^/]*)$ ./index.php?page=list [QSA] +RewriteRule ^show/([^/]*)$ ./index.php?page=show&feed=$1 [QSA,L] + \ No newline at end of file diff --git a/assets/audiojs/LICENSE b/assets/audiojs/LICENSE new file mode 100644 index 0000000..4fbf29d --- /dev/null +++ b/assets/audiojs/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010 Anthony Kolber (http://aestheticallyloyal.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/assets/audiojs/audio.min.js b/assets/audiojs/audio.min.js new file mode 100644 index 0000000..e5fde2b --- /dev/null +++ b/assets/audiojs/audio.min.js @@ -0,0 +1,24 @@ +(function(h,o,g){var p=function(){for(var b=/audio(.min)?.js.*/,a=document.getElementsByTagName("script"),c=0,d=a.length;c ',settings:{autoplay:false,loop:false,preload:true,imageLocation:p+"player-graphics.gif",swfLocation:p+"audiojs.swf",useFlash:function(){var b=document.createElement("audio");return!(b.canPlayType&&b.canPlayType("audio/mpeg;").replace(/no/,""))}(),hasFlash:function(){if(navigator.plugins&&navigator.plugins.length&&navigator.plugins["Shockwave Flash"])return true;else if(navigator.mimeTypes&&navigator.mimeTypes.length){var b= +navigator.mimeTypes["application/x-shockwave-flash"];return b&&b.enabledPlugin}else try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash");return true}catch(a){}return false}(),createPlayer:{markup:'

00:00/00:00
', +playPauseClass:"play-pause",scrubberClass:"scrubber",progressClass:"progress",loaderClass:"loaded",timeClass:"time",durationClass:"duration",playedClass:"played",errorMessageClass:"error-message",playingClass:"playing",loadingClass:"loading",errorClass:"error"},css:' .audiojs audio { position: absolute; left: -1px; } .audiojs { width: 460px; height: 36px; background: #404040; overflow: hidden; font-family: monospace; font-size: 12px; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444), color-stop(0.5, #555), color-stop(0.51, #444), color-stop(1, #444)); background-image: -moz-linear-gradient(center top, #444 0%, #555 50%, #444 51%, #444 100%); -webkit-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); -moz-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); -o-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.3); } .audiojs .play-pause { width: 25px; height: 40px; padding: 4px 6px; margin: 0px; float: left; overflow: hidden; border-right: 1px solid #000; } .audiojs p { display: none; width: 25px; height: 40px; margin: 0px; cursor: pointer; } .audiojs .play { display: block; } .audiojs .scrubber { position: relative; float: left; width: 280px; background: #5a5a5a; height: 14px; margin: 10px; border-top: 1px solid #3f3f3f; border-left: 0px; border-bottom: 0px; overflow: hidden; } .audiojs .progress { position: absolute; top: 0px; left: 0px; height: 14px; width: 0px; background: #ccc; z-index: 1; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ccc), color-stop(0.5, #ddd), color-stop(0.51, #ccc), color-stop(1, #ccc)); background-image: -moz-linear-gradient(center top, #ccc 0%, #ddd 50%, #ccc 51%, #ccc 100%); } .audiojs .loaded { position: absolute; top: 0px; left: 0px; height: 14px; width: 0px; background: #000; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #222), color-stop(0.5, #333), color-stop(0.51, #222), color-stop(1, #222)); background-image: -moz-linear-gradient(center top, #222 0%, #333 50%, #222 51%, #222 100%); } .audiojs .time { float: left; height: 36px; line-height: 36px; margin: 0px 0px 0px 6px; padding: 0px 6px 0px 12px; border-left: 1px solid #000; color: #ddd; text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5); } .audiojs .time em { padding: 0px 2px 0px 0px; color: #f9f9f9; font-style: normal; } .audiojs .time strong { padding: 0px 0px 0px 2px; font-weight: normal; } .audiojs .error-message { float: left; display: none; margin: 0px 10px; height: 36px; width: 400px; overflow: hidden; line-height: 36px; white-space: nowrap; color: #fff; text-overflow: ellipsis; -o-text-overflow: ellipsis; -icab-text-overflow: ellipsis; -khtml-text-overflow: ellipsis; -moz-text-overflow: ellipsis; -webkit-text-overflow: ellipsis; } .audiojs .error-message a { color: #eee; text-decoration: none; padding-bottom: 1px; border-bottom: 1px solid #999; white-space: wrap; } .audiojs .play { background: url("$1") -2px -1px no-repeat; } .audiojs .loading { background: url("$1") -2px -31px no-repeat; } .audiojs .error { background: url("$1") -2px -61px no-repeat; } .audiojs .pause { background: url("$1") -2px -91px no-repeat; } .playing .play, .playing .loading, .playing .error { display: none; } .playing .pause { display: block; } .loading .play, .loading .pause, .loading .error { display: none; } .loading .loading { display: block; } .error .time, .error .play, .error .pause, .error .scrubber, .error .loading { display: none; } .error .error { display: block; } .error .play-pause p { cursor: auto; } .error .error-message { display: block; }', +trackEnded:function(){},flashError:function(){var b=this.settings.createPlayer,a=j(b.errorMessageClass,this.wrapper),c='Missing flash player plugin.';if(this.mp3)c+=' Download audio file.';g[h].helpers.removeClass(this.wrapper,b.loadingClass);g[h].helpers.addClass(this.wrapper,b.errorClass);a.innerHTML=c},loadError:function(){var b=this.settings.createPlayer,a=j(b.errorMessageClass,this.wrapper);g[h].helpers.removeClass(this.wrapper, +b.loadingClass);g[h].helpers.addClass(this.wrapper,b.errorClass);a.innerHTML='Error loading: "'+this.mp3+'"'},init:function(){g[h].helpers.addClass(this.wrapper,this.settings.createPlayer.loadingClass)},loadStarted:function(){var b=this.settings.createPlayer,a=j(b.durationClass,this.wrapper),c=Math.floor(this.duration/60),d=Math.floor(this.duration%60);g[h].helpers.removeClass(this.wrapper,b.loadingClass);a.innerHTML=(c<10?"0":"")+c+":"+(d<10?"0":"")+d},loadProgress:function(b){var a=this.settings.createPlayer, +c=j(a.scrubberClass,this.wrapper);j(a.loaderClass,this.wrapper).style.width=c.offsetWidth*b+"px"},playPause:function(){this.playing?this.settings.play():this.settings.pause()},play:function(){g[h].helpers.addClass(this.wrapper,this.settings.createPlayer.playingClass)},pause:function(){g[h].helpers.removeClass(this.wrapper,this.settings.createPlayer.playingClass)},updatePlayhead:function(b){var a=this.settings.createPlayer,c=j(a.scrubberClass,this.wrapper);j(a.progressClass,this.wrapper).style.width= +c.offsetWidth*b+"px";a=j(a.playedClass,this.wrapper);c=this.duration*b;b=Math.floor(c/60);c=Math.floor(c%60);a.innerHTML=(b<10?"0":"")+b+":"+(c<10?"0":"")+c}},create:function(b,a){a=a||{};return b.length?this.createAll(a,b):this.newInstance(b,a)},createAll:function(b,a){var c=a||document.getElementsByTagName("audio"),d=[];b=b||{};for(var e=0,i=c.length;ea.loadedPercent)){a.updatePlayhead.call(a,[c]);a.element.skipTo(c)}};a.updatePlayhead=function(c){a.settings.updatePlayhead.apply(a,[c])};a.play=function(){if(!a.settings.preload){a.settings.preload=true;a.element.init(a.mp3)}a.playing=true;a.element.pplay();a.settings.play.apply(a)};a.pause=function(){a.playing=false;a.element.ppause();a.settings.pause.apply(a)};a.setVolume=function(c){a.element.setVolume(c)};a.loadStarted=function(){a.swfReady= +true;a.settings.preload&&a.element.init(a.mp3);a.settings.autoplay&&a.play.apply(a)}},injectFlash:function(b,a){var c=this.flashSource.replace(/\$1/g,a);c=c.replace(/\$2/g,b.settings.swfLocation);c=c.replace(/\$3/g,+new Date+Math.random());var d=b.wrapper.innerHTML,e=document.createElement("div");e.innerHTML=c+d;b.wrapper.innerHTML=e.innerHTML;b.element=this.helpers.getSwf(a)},helpers:{merge:function(b,a){for(attr in a)if(b.hasOwnProperty(attr)||a.hasOwnProperty(attr))b[attr]=a[attr]},clone:function(b){if(b== +null||typeof b!=="object")return b;var a=new b.constructor,c;for(c in b)a[c]=arguments.callee(b[c]);return a},addClass:function(b,a){RegExp("(\\s|^)"+a+"(\\s|$)").test(b.className)||(b.className+=" "+a)},removeClass:function(b,a){b.className=b.className.replace(RegExp("(\\s|^)"+a+"(\\s|$)")," ")},injectCss:function(b,a){for(var c="",d=document.getElementsByTagName("style"),e=a.replace(/\$1/g,b.settings.imageLocation),i=0,f=d.length;i1?b[b.length-1]:b}},events:{memoryLeaking:false,listeners:[],addListener:function(b,a,c){if(b.addEventListener)b.addEventListener(a,c,false);else if(b.attachEvent){this.listeners.push(b);if(!this.memoryLeaking){window.attachEvent("onunload",function(){if(this.listeners)for(var d=0,e=this.listeners.length;d-1)d||b.init.apply(b);if(b.element.readyState>1){b.settings.autoplay&&b.play.apply(b);clearInterval(a);c=setInterval(function(){b.loadProgress.apply(b);b.loadedPercent>=1&&clearInterval(c)})}},10);b.readyTimer=a;b.loadTimer=c}},purge:function(b){var a=b.attributes,c;if(a)for(c=0;cthis.loadedPercent)){this.element.currentTime=this.duration*b;this.updatePlayhead()}},load:function(b){this.loadStartedCalled=false;this.source.setAttribute("src",b);this.element.load();this.mp3=b;g[h].events.trackLoadProgress(this)}, +loadError:function(){this.settings.loadError.apply(this)},init:function(){this.settings.init.apply(this)},loadStarted:function(){if(!this.element.duration)return false;this.duration=this.element.duration;this.updatePlayhead();this.settings.loadStarted.apply(this)},loadProgress:function(){if(this.element.buffered!=null&&this.element.buffered.length){if(!this.loadStartedCalled)this.loadStartedCalled=this.loadStarted();this.loadedPercent=this.element.buffered.end(this.element.buffered.length-1)/this.duration; +this.settings.loadProgress.apply(this,[this.loadedPercent])}},playPause:function(){this.playing?this.pause():this.play()},play:function(){/(ipod|iphone|ipad)/i.test(navigator.userAgent)&&this.element.readyState==0&&this.init.apply(this);if(!this.settings.preload){this.settings.preload=true;this.element.setAttribute("preload","auto");g[h].events.trackLoadProgress(this)}this.playing=true;this.element.play();this.settings.play.apply(this)},pause:function(){this.playing=false;this.element.pause();this.settings.pause.apply(this)}, +setVolume:function(b){this.element.volume=b},trackEnded:function(){this.skipTo.apply(this,[0]);this.settings.loop||this.pause.apply(this);this.settings.trackEnded.apply(this)}};var j=function(b,a){var c=[];a=a||document;if(a.getElementsByClassName)c=a.getElementsByClassName(b);else{var d,e,i=a.getElementsByTagName("*"),f=RegExp("(^|\\s)"+b+"(\\s|$)");d=0;for(e=i.length;d1?c:c[0]}})("audiojs","audiojsInstance",this); diff --git a/assets/audiojs/audiojs.swf b/assets/audiojs/audiojs.swf new file mode 100644 index 0000000000000000000000000000000000000000..483599fc8273d0ccaaa935aa115a65e05ffe27ec GIT binary patch literal 1644 zcmV-y29x<|i+I>}9ZyU!Io|(N2xxDB?iMA-oqAl4<6iTFI$B7h~i6YUC zRM{(t3J?S^%+c{MW6dGj0))A=xcx$#VP^P_dew}^u;~1OWo3(X)2B&S4o$y7= zVL^AjeghOap&dHBxnX*Ty!z7NXVqubjhp-gok9fIylJ#~YfL7xmkh60@B5w^8PJmj zR7vvf6hYCC4jnt_a=#h5$F6spmbi%ujNx+@dUp|5F|qD2_b6gVyxDq_tX=y_k1XWP zEpAko8@1|6W4V#GA)@Q`->5x^zy>za*6^>=I@%;3K79CIlVFEc_{#Y2O_Y58@TbLp z)L_Sd)L3NN-VXu#>)4MJAqXMMXFa}*hS3rt;J(QvN-y=eX|sIWi(GTF%UqW`NIvmw zGoLQ=6R~^Rf!*VNOW1`y-#hYo5G0=34t?7_%5Uo}-}h34`X=ffa$iXtI%uSj(wTP9 zci6ew?)!GgGw+PFq!NhwO43EfjQnIScwwCoDBM zw)+R3mbBV(O>P$3`nPYk-fily_jX$ctzl-G$;`WU5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-lk=9XiqieEhtZIPc9sQ$FRKD7^`NwG}5K4Gy;y*{0!+KmpsKFM(GyTpcX zWB8Slb~-@og&~jAuo3?B5_hadia^<_DLImCBG6;kz)1bxMuxf!uXKj!bD!UapP?Fq zd;cyL0YKM@Wh)>UJh}XQMw?D7tDJRW;j3d;StJWSEaNXZ5!av-%bim?u~44%U@Zlo z#ByxOzFYU`I3UDryfAHGaS3mQc2qS`ba(^K(8fVA&byO>s KA7@~Jh5rN$ejversion = "1.0"; + $this->build = "20130725"; + + self::setDefaults(); + self::setConfig($config); + } + + public function translateFeed($feed = null) + { + $data = $this->feedslist; + if (is_readable($data)) { + $data = json_decode(file_get_contents($data)); + $this->feeds = $data; + } else { + return $this->feed_url; + } + + return $this->feeds->$feed; + } + + public function buildPage($page = 'list', $feed = null) + { + // Set our template path to shorthand + $tpl = $this->templatepath; + require_once $tpl . '/header.php'; + + $feed = $this->translateFeed($feed); + + $simplepie = new \SimplePie(); + $simplepie->set_feed_url($feed); + $simplepie->init(); + $simplepie->handle_content_type(); + + $data['this'] = $this; + + switch ($page) { + case 'show': + $data['feed'] = $simplepie; + break; + case 'list': + default: + $data['feeds'] = $this->feedslist; + break; + } + + if (is_readable($tpl . DIRECTORY_SEPARATOR . $page . '.php')) { + require_once $tpl . DIRECTORY_SEPARATOR . $page . '.php'; + } + + require_once $tpl . '/footer.php'; + return true; + } + + public function getFeedTitle($feed = null) + { + if (empty($feed)) { + return 'Feed "'.$feed.'" not known.'; + } else { + $feed = $this->translateFeed($feed); + + $simplepie = new \SimplePie(); + $simplepie->set_feed_url($feed); + $simplepie->init(); + $simplepie->handle_content_type(); + + return $simplepie->get_title(); + } + return false; + } + + public function lnk($link = null, $text = '') + { + return '' . $text . ''; + } + + public function lst($text = null) + { + return '
  • ' . $text . '
  • '; + } + + public function currentDir() + { + $path = dirname($_SERVER["PHP_SELF"]); + $position = strrpos($path, '/') + 1; + return '/' . substr($path, $position); + } + + public function setDefaults() + { + $path = pathinfo(__FILE__); + $this->basepath = dirname($path['dirname']) . DIRECTORY_SEPARATOR; + $this->cache_location = $this->basepath . 'cache'; + $this->feed_url = 'http://feeds.5by5.tv/master'; + $this->useragent = 'RSSAudioPlayer/'. $this->version + .' (Feed Parser; http://github.com/ivuorinen/rss-audio-player; ' + .'Allow like Gecko) Build/'. $this->build; + $this->templatepath = $this->basepath . 'templates'; + $this->feedslist = $this->basepath . 'feeds.json'; + $this->baseurl = $this->currentDir(); + } + + public function setConfig($config = null) + { + if (empty($config)) { + return false; + } + + foreach ($config as $key => $value) { + $this->$key = $value; + } + + return true; + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..67bf99f --- /dev/null +++ b/index.php @@ -0,0 +1,44 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * @category Default + * @package ivuorinen\RSS_Audio_Player + * @author Ismo Vuorinen + * @copyright 2012 Ismo Vuorinen. + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 1.0 + * @link http://github.com/ivuorinen/rss-audio-player + */ + +require_once 'vendor/simplepie/simplepie/autoloader.php'; +require_once 'inc/rss-audio-player.php'; + +$page = (empty($_GET['page'])) ? 'list' : $_GET['page']; +$feed = (empty($_GET['feed'])) ? '5by5master' : $_GET['feed']; + +$rap = new \ivuorinen\RSSAudioPlayer(); + +$rap->buildPage($page, $feed); diff --git a/templates/footer.php b/templates/footer.php new file mode 100644 index 0000000..bd564dc --- /dev/null +++ b/templates/footer.php @@ -0,0 +1,34 @@ + + + + + + + + + + \ No newline at end of file diff --git a/templates/header.php b/templates/header.php new file mode 100644 index 0000000..b5d8c4e --- /dev/null +++ b/templates/header.php @@ -0,0 +1,23 @@ + + + + + + + + + RSS Audio Player + + + + + + + +
    + +
    diff --git a/templates/list.php b/templates/list.php new file mode 100644 index 0000000..ba926a5 --- /dev/null +++ b/templates/list.php @@ -0,0 +1,26 @@ + +
    +
    +
    + +

    Our known feeds

    +
      + +feeds as $key => $url) { + $title = $this->getFeedTitle($key); + echo "\t\t\t\t" . $this->lst( + $this->lnk( + $this->baseurl . '/show/' . $key, // Our link + $title + ) + ). "\n"; +} + +?> + +
    +
    +
    +
    \ No newline at end of file diff --git a/templates/show.php b/templates/show.php new file mode 100644 index 0000000..9fab235 --- /dev/null +++ b/templates/show.php @@ -0,0 +1,48 @@ + + +
    +
    +
    + +

    get_title(); + ?>

    +
    +

    get_description(); ?>

    +
    + +get_items(); + +if (! empty($items)) { + + echo ''."\n"; + echo '
      ' . "\n"; + + foreach ($items as $item) { + + if (($enclosure = $item->get_enclosure())) { + $link = $enclosure->get_link(); + } else { + $link = null; + } + + echo "\t\t\t\t
    1. " + . '' + . $item->get_title() + . '' + ."
    2. \n"; + } + + echo '
    ' . "\n"; +} +?> +
    +
    +
    \ No newline at end of file diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 0000000..e69de29