From f57f52dda9ad03255930da0010f00ed59f348159 Mon Sep 17 00:00:00 2001 From: harrys-pel Date: Mon, 15 Feb 2016 21:23:39 +0200 Subject: [PATCH 1/4] YouTube plug-in Create playlists and play your favorite songs using urls from YouTube --- YouTube plug-in/.gitattributes | 17 + YouTube plug-in/.gitignore | 47 ++ YouTube plug-in/README.md | 2 + YouTube plug-in/button.png | Bin 0 -> 1492 bytes YouTube plug-in/cover.png | Bin 0 -> 1997 bytes YouTube plug-in/index.html | 145 ++++ YouTube plug-in/js/itunes.js | 42 ++ YouTube plug-in/js/jplayer-development.js | 865 ++++++++++++++++++++++ YouTube plug-in/js/jplayer-library.min.js | 148 ++++ YouTube plug-in/js/jquery-1.12.0.min.js | 5 + YouTube plug-in/player.css | 397 ++++++++++ 11 files changed, 1668 insertions(+) create mode 100644 YouTube plug-in/.gitattributes create mode 100644 YouTube plug-in/.gitignore create mode 100644 YouTube plug-in/README.md create mode 100644 YouTube plug-in/button.png create mode 100644 YouTube plug-in/cover.png create mode 100644 YouTube plug-in/index.html create mode 100644 YouTube plug-in/js/itunes.js create mode 100644 YouTube plug-in/js/jplayer-development.js create mode 100644 YouTube plug-in/js/jplayer-library.min.js create mode 100644 YouTube plug-in/js/jquery-1.12.0.min.js create mode 100644 YouTube plug-in/player.css diff --git a/YouTube plug-in/.gitattributes b/YouTube plug-in/.gitattributes new file mode 100644 index 00000000..bdb0cabc --- /dev/null +++ b/YouTube plug-in/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/YouTube plug-in/.gitignore b/YouTube plug-in/.gitignore new file mode 100644 index 00000000..cd2946ad --- /dev/null +++ b/YouTube plug-in/.gitignore @@ -0,0 +1,47 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/YouTube plug-in/README.md b/YouTube plug-in/README.md new file mode 100644 index 00000000..987961ad --- /dev/null +++ b/YouTube plug-in/README.md @@ -0,0 +1,2 @@ +# youtube-plugin-for-jplayer +A youtube plug-in of jPlayer for selecting and playing your favorite songs from youtube. diff --git a/YouTube plug-in/button.png b/YouTube plug-in/button.png new file mode 100644 index 0000000000000000000000000000000000000000..3e4866c394060e0a877614189cc1294f38d272e9 GIT binary patch literal 1492 zcmbVMX;2$w7+wK86^k&Qg^IIoe^{g>*@PsJA!Q(<UpTQVA6tLb8w*HoM&{O`wO` z4l|Z2)7F+lZE42JI8$xy^unpNFgV=zeTDnJ!Zns-05_CSe~3T)W_Q11p67X=?|a{G z&qaiVxHx+_0|4M63q=%6|Bmh5>BxL{O@DHM>D+0lijE`_Xrr1!fgmjrkAgB>oro$> zwKnxwIT`=}ju56)(JJ|2k%quoY8!@S!bye=00Ds}QmsisX)qp5#Pnjw`sfJ+Vp=g2 z#g}vBqy*Jrp=lHvnHHwhq$O$mwNT&zFu){Y1aOpAgC;y#ZxETp(1xyv8QYfG5V!%M zlf=+7Q!04`C?O~mFJ{#E_1rNfDcEG#Xh(9*dw7*|5LAzfFV7^lcd+iDcYS2&^ zNn?Z_v?;3Ni4)3^58U4AY9FFarB=q*955&x2tp-%lvv1_`ASAtyM9gYf+9T!hf1 z;HaLqbG6U82e;+gN&zRC$OuYd$5HJ;ion5*EsL=2y-2pz+vIAu_kwK8Wiw{jw#5D; z(e@>#dThh3vSlV)g^%i)YNwd8KGzX=g1HhuMjTd3o0^(xYip~ktH;O3>+0&-+uQ5w z>pMC+8XFsjhK5>OTgS%6Mn*=~*Vp^|`_DJhwnnwp-TUR+$9oSZB# zFJE3>o}Zr|9v)s@U9G67SXfwCSy@?HS}H9qU0YkLtgNi6s$xQC-aC@X7#7lsut;Y5 zKN{c`ef2y5yr7gJK}u6c)iRjKI4+hr+Qq?$4}qPQ@&Bky7e9FFaH>i!YkBuGfp;FeEy#C zQ%~^X;FYr$_ZQzZFYg!$4*9cePx8Z;?!4Y^>GiCyfP%*QbMmtk&Izx@d=Qr(dgE)J z+6y-y6BfO?lKbIf#JoqBo^v7hTHM4b74G@S#Z-FzEAP(O%4*k-h}Dy-+g(53fA^`Y z{PEP7)A{?c>6fspMg()X6xDL$x5|(&?qw7j59MFZ+`XFP;ayeCcStL|>*VfwbcT1} zmmN9gu^fJZcY2?0=_IcSl46A#UQZ#O0)8bz+n+lFTocO^QJNo;V^SSN2 z9~5U@`#5~ySFfM$9^F6ua^B_aZ-p+6g*#;#=;=Iu?TNRg*6=@yvH?dRJL6*D$ejn# Pw*Rb58iw2ojyv-=FiDI+ literal 0 HcmV?d00001 diff --git a/YouTube plug-in/cover.png b/YouTube plug-in/cover.png new file mode 100644 index 0000000000000000000000000000000000000000..c6a8782af3489ffb25ad42c05924b82cf3a3df45 GIT binary patch literal 1997 zcmb_dc~BE~7>!!njx*G%9nYdMs3TZ%2|*UZnM9xjV!~}XLb5`N$%f4WN!k=?5e1PH zDR@)~7%Zbms1#9*kWyw4wID~M(ne}23K$TCh#C;OLBLL@_?J7o`#a{n_r2fueY2a% z3fO72WbG0R24m&xLt~?(+48)<2z~3w=a!khJ-Qw0Ujj8b1fLWR47K-7>ujCRLtcifCx4gj1!2cxFM|$hZXRt zxKKwXkty~D;{`r)805$Uf_U--o--fk?uK=h0;qrxM7UU~aIZ)LNU6AKT>zb1wh1`w zGz3YY;$E2wW3sT`5Da1+@!RcrL=p*0q2NgljuZ;%6D*lXA`^({O|d6A0FD%Z?1Y`U zaA-7`zXxE`7&EcZ6%`kcAYy<(NJ&Y-r)Ylp~QeU3~~_&4uYV)vsq-tLkJ{^hs0QK4h6e4 zR3PF*DH7XhJd+9diX;eE!~=b4R2-^+7YO(Ook(;b6Ujtxx)Yjpx}z7}*^@!1&>3X9 z7sY`{n&r|UUXl#7g+(}(i@ z-QC@(RH~<^r;m>hgTYWLm4$_c5CrAs=F(`i-Me>3L`1MyECfM@hle>FPGe(ZYHF%h ztJUlE>FMdmj~}nEuTM@+c5!hrnM{L&gA)@I{{H^=@87SitP}_Yfq{V)6&2mx-JzkO za=E;ysK{tEj*X3Vc6OdUd$y&erMbCTr_*I+Wwo`n84QNIckc>?!ltIC=g*(}`T51f z#K>f_goK3H*x0D3sJOVej*gDr-rkaulK%eww6wJG@$tO8yz1)enwpxCkr9PLk)NM` z^5jXiTHVvr)6mdRT3V{nXsW8Jf`fx^+_-V@;K8Y>DO+3HjX!RtqTi0~zBJDu>F)!E zPzXo*D1%F`-e_9Bd|`>Ve5e*00v}FIHPbe5Q3P=jU-d`QDg6eUoW)op5NRZV5fyaJWX{k4tD%wem| zeyX&`8x{I!`NCJWqczH-c2>9g^2Ym%j&PnmT?6$!kON^X^98rzeRb^UC0WiL;X{;K zS8`WV>4_&#HSI@rcx%FHeR&sEF8g~lvHn=<9W7l~cYWQ(bpH@Rd8mvf}= zNtqk8f%?L}uzj229w2{gH;_5$dHPbhnvhZ3)*F&;R^D!N+GMV7^*CW@5vo<0cdB-# zuY|g9I@wjXt?OnUU>4I!lLZp{%ENV=+wYWY*?;fyEuWjfl^vl;G9$xy?WgWGKHs`_ zOS|^!XFjUBFWA5?W7*X}Q}!ku9*G<-9jp9)^u48JmoMf8>6|zU+2>!qa9sYu1@iJLEr3o>0#Peqp4o{8d}Snpx}`Q5kMj{hkn<$)5j2-6yn V<8=<(aoh5P^`!^UG+r@Z{{wBoVt@bu literal 0 HcmV?d00001 diff --git a/YouTube plug-in/index.html b/YouTube plug-in/index.html new file mode 100644 index 00000000..0ddd4923 --- /dev/null +++ b/YouTube plug-in/index.html @@ -0,0 +1,145 @@ + + + + + XARIS JPLAYER REMAKE + + + + + + + + + + +
+ +
+ +
+
+
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
-
+
+ +
00:00
+
+
00:00
+ +
+ +
+ +
+ + + +
+ +
+ + + +
+ +
+ +
Ταξινόμηση κατά δημοτικότητα τραγουδιού
+ +
+ +
+ + +
+ +
+ +
Πρόσθεσε τραγούδι στην λίστα αναπαραγωγής από το youtube
+ +
+ +
+
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/YouTube plug-in/js/itunes.js b/YouTube plug-in/js/itunes.js new file mode 100644 index 00000000..ba856246 --- /dev/null +++ b/YouTube plug-in/js/itunes.js @@ -0,0 +1,42 @@ +var iTunesStoreSearch; +(function($){ + iTunesStoreSearch = function(options){ + var placeholder = $(this); + var settings = $(this).data('itunesstoresearchsettings'); + if(!settings){ + settings = { + 'term':'', + 'country':'', + 'media':'', + 'entity':'', + 'attribute':'', + 'limit':'', + 'lang':'', + 'version':'', + 'explicit':'', + 'callback':function(data){} + } + }; + var IntFunc = { + }; + + if(typeof(options)=='string'){ + if(IntFunc[options])IntFunc[options].apply(null,Array.prototype.slice.call(arguments,1)); + }else if(options){ + settings = $.extend(settings,options||{}); + $(this).data('itunesstoresearchsettings',settings); + + var pars = $.extend({},settings); + delete pars['callback']; + $.getJSON('https://itunes.apple.com/search?callback=?',pars,function(data){ + settings.callback(data) + }); + } + }; + $.fn.extend({ + itunesstoresearch:function(){ + var args = arguments; + this.each(function(){iTunesStoreSearch.apply(this,args)}); + } + }); +})(jQuery); \ No newline at end of file diff --git a/YouTube plug-in/js/jplayer-development.js b/YouTube plug-in/js/jplayer-development.js new file mode 100644 index 00000000..502ada63 --- /dev/null +++ b/YouTube plug-in/js/jplayer-development.js @@ -0,0 +1,865 @@ +$(document).ready(function(){ + + // ARRAY FOR STORING INFORMATION OF PLAYLIST TRACKS + var playlist = []; + + // DEFINE OUR PLAYER TO HTML TAG '#jplayer' AND INITIALIZE JPLAYER LIBRARY + var player = new MediaElementPlayer('#player1', { + + defaultVideoWidth: 960, + defaultVideoHeight: 410, + features: ['playpause', 'progress', 'current', 'duration', 'volume', 'fullscreen'], + success: function (media, domElement, player) { + + drag('#sound-bar','#sound-bar-inner',media,'volume'); + drag('#duration-bar','#duration-bar-inner',media,'duration'); + progress(media); + + } + + }); + + + //localStorage.removeItem("musiclist"); + + // DECLARE OUR DATA STORAGE SYSTEM INTO A VARIABLE + var items = localStorage.getItem("musiclist"); + + // IF DATA EXISTS RETRIEVE IT AND APPENDING TO HTML TAGS IN HTML PLAYLIST + if ( items ) { + + var arr = JSON.parse(items); + + arr.forEach(function(i,j){ + + $('#tracks').append( + + '
'+ + '
'+ + '
'+i.id+'
'+ + '
'+ + ''+i.title+' - '+ + ' '+i.artist+''+ + '
'+ + '
'+ + '
track thumbnail
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
' + + ); + + playlist.push( + + { + + id: i.id-1, + title: i.title, + artist: i.artist, + m4v: i.m4v, + thumbnail: i.thumbnail, + album: i.album, + country: i.country, + date: i.date, + gengre: i.gengre, + rate: i.rate + + } + + ); + + }); + + } + + $('.star-rating').children('.star').each(function(){ + + var attr = $(this).parent().attr('data-rate'); + var len = $(this).attr('data-length'); + + if ( len <= attr) { + + $(this).css('color','#292929'); + + } + else { + + $(this).css('color',''); + + } + + }); + + // ON CLICK SUBMIT TRACK BUTTON + $('#submit-track-btn').on('click', function(){ + + // HANDLING IF ERROR EXISTS ON SUBMITTING TRACK, IF VARIABLE GREATER THAN 0 THEN EXISTS ERROR + var error = 0; + + // EACH USER INPUT VALUES HANDLE IF IS EMPTY + $('.track-info > input').each(function(){ + + var id = $(this).attr('id'); + var length = $(this).val().length; + + if ( length < 1 && id !== 'get-track-url' ) { + + $(this).css('border-color','#f00'); + alert('Παρακαλώ συμπλήρωσε τα πεδίο με το κόκκινο πλαίσιο'); + error++; + + } + else { + + $(this).css('border-color',''); + + } + + // CHECK IF URL INPUT MATCH WITH YOUTUBE ADDRESS, OTHERWISE DISABLE SUBMITTING + if ( id == 'get-track-url' ) { + + var val = $(this).val(); + var isYoutube = val.match(/(?:youtu|youtube)(?:\.com|\.be)\/([\w\W]+)/i); + + if ( isYoutube && val.length > 1 ) { + + $(this).css('border-color',''); + + } + else { + + $(this).css('border-color','#f00'); + alert('Τοπεθέτησε μια διεύθυνση url απο το youtube που αντιστοιχεί σε βίντεο. Για παράδειγμα: https://www.youtube.com/watch?v=TapXs54Ah3E'); + error++; + + } + + } + + }); + + // IF THERE IS NOT ERROR ON SUBMITTING STORE TRACK IN PLAYLIST ARRAY + if ( error == 0 ) { + + // GET VALUES FROM USER INPUT + var artist = $('#get-track-artist').val(); + var title = $('#get-track-title').val(); + var url = $('#get-track-url').val(); + var listLength = $('#tracks').children().length; + var number = listLength+1; + var thumbnail, album, country, relDate, gengre; + + $('#get-track-info').slideUp('slow'); + + // SEARCH TO ITUNES DATABASE TO RETRIEVE TRACK ARTWORK AND OTHER INFO + $('#get-track-info').itunesstoresearch({ + + 'term': artist+' - '+title, + 'limit': 1, + 'callback': function(data){ + + var check = data.results[0]; + + if ( check === undefined ) { + + thumbnail = 'track thumbnail'; + album = 'Δεν υπάρχουν στοιχεία'; + country = 'Δεν υπάρχουν στοιχεία'; + relDate = 'Δεν υπάρχουν στοιχεία'; + gengre = 'Δεν υπάρχουν στοιχεία'; + + } + else { + + var artwork = data.results[0].artworkUrl100; + var replace = artwork.replace("100x100bb", "500x500bb"); + thumbnail = 'track thumbnail'; + album = data.results[0].collectionName; + country = data.results[0].country; + relDate = data.results[0].releaseDate; + relDate = relDate.substring(0, relDate.indexOf('T')); + gengre = data.results[0].primaryGenreName; + + } + + // APPEND TRACK TO HTML TAGS + $('#tracks').append( + + '
'+ + '
'+ + '
'+number+'
'+ + '
'+ + ''+title+' - '+ + ' '+artist+''+ + ''+ + '
'+ + '
'+ + '
'+thumbnail+'
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
' + + ); + + // CLEAR USER INPUT VALUES + $('.track-info > input').each(function(){ + + $(this).val(''); + + }); + + playlist = []; + + // PUSH TRACK TO ARRAY + $('#tracks > .track').each(function(){ + + playlist.push( + + { + + id: $(this).children('.track-number').text(), + title: $(this).children('.track-data').children('.track-title').text(), + artist: $(this).children('.track-data').children('.track-artist').text(), + m4v: $(this).attr('data-track-url'), + thumbnail: $(this).children('.track-thumbnail').children('img').attr('src'), + album: $(this).children('.track-detail').attr('data-track-album'), + country: $(this).children('.track-detail').attr('data-track-country'), + date: $(this).children('.track-detail').attr('data-track-date'), + gengre: $(this).children('.track-detail').attr('data-track-gengre'), + rate: $(this).children('.star-rating').attr('data-rate') + + } + + ); + + }); + + var listString = JSON.stringify(playlist); + + // STORAGE ARRAY TO LOCAL STORAGE SYSTEM OF BROWSER + localStorage.setItem("musiclist", listString); + + } + + }); + + } + + }); + + var click = 0; + + // ON CLICK PLAY BUTTON + $('#player-play').on('click', function(){ + + if ( $('#main-player').attr('data-track-id') == '' && click < 1 ) { + + click++; + player.pause(); + player.setSrc( playlist[0].m4v ); + player.media.load(); + player.play(); + playerData(playlist[0].id,playlist[0].title,playlist[0].artist,playlist[0].m4v,playlist[0].thumbnail,playlist[0].album,playlist[0].country,playlist[0].date,playlist[0].gengre); + $(this).hide(); + $('#main-player').attr('data-status','playing'); + $('#player-pause').show(); + duration(); + + } + + else { + + player.play(); + + $(this).hide(); + + $('#main-player').attr('data-status','playing'); + + $('#player-pause').show(); + + $('#main-player').removeClass('pause'); + + $('#main-player').addClass('play'); + + duration(); + + } + + }); + + + // ON CLICK PAUSE BUTTON + $('#player-pause').on('click', function(){ + + player.pause(); + + $(this).hide(); + + $('#main-player').attr('data-status','pausing'); + + $('#player-play').show(); + + $('#main-player').removeClass('play'); + + $('#main-player').addClass('pause'); + + }); + + // ON CLICK NEXT BUTTON + $('#player-next').on('click', function(){ + + var id = $('#main-player').attr('data-track-id'); + + var parse = parseInt(id); + + var minus = playlist.length - 1; + + var sum = parse + 1; + + var num; + + var next; + + var shuffleStatus = $('#player-shuffle').attr('class'); + + $('.track-number').each(function(){ + + if ( $(this).text() == sum ) { + + next = $(this).parent().next().children('.track-number').text() - 1; + + } + + }); + + if ( shuffleStatus == 'shuffle-on' ) { + + num = shufflePlay(minus); + + } + else { + + if ( next == -1 ) { + + num = $('.track').first().children('.track-number').text() - 1; + + } + else { + + num = next; + + } + + } + + player.pause(); + player.setSrc( playlist[num].m4v ); + player.media.load(); + player.play(); + playerData(playlist[num].id,playlist[num].title,playlist[num].artist,playlist[num].m4v,playlist[num].thumbnail,playlist[num].album,playlist[num].country,playlist[num].date,playlist[num].gengre); + duration(); + + }); + + // ON CLICK PREVIOUS BUTTON + $('#player-previous').on('click', function(){ + + var id = $('#main-player').attr('data-track-id'); + + var parse = parseInt(id); + + var sum = parse + 1; + + var minus = playlist.length - 1; + + var num; + + var prev; + + var shuffleStatus = $('#player-shuffle').attr('class'); + + $('.track-number').each(function(){ + + if ( $(this).text() == sum ) { + + prev = $(this).parent().prev().children('.track-number').text() - 1; + + } + + }); + + if ( shuffleStatus == 'shuffle-on' ) { + + num = shufflePlay(minus); + + } + else { + + + if ( prev == -1 ) { + + num = $('.track').last().children('.track-number').text() - 1; + + } + else { + + num = prev; + + } + + } + + player.pause(); + player.setSrc( playlist[num].m4v ); + player.media.load(); + player.play(); + playerData(playlist[num].id,playlist[num].title,playlist[num].artist,playlist[num].m4v,playlist[num].thumbnail,playlist[num].album,playlist[num].country,playlist[num].date,playlist[num].gengre); + duration(); + + }); + + $('#player-shuffle').on('click', function(){ + + var attr = $(this).attr('class'); + + if ( attr == 'shuffle-off' ) { + + $(this).removeClass('shuffle-off').addClass('shuffle-on').css('color','#7ba2c5'); + + } + if ( attr == 'shuffle-on' ) { + + $(this).removeClass('shuffle-on').addClass('shuffle-off').css('color',''); + + } + + }); + + // ON CLICK IN TRACK + $('.track').on('click', function(){ + + var id = $(this).children('.track-number').text(); + var num = parseInt(id); + var sum = num - 1; + player.pause(); + player.setSrc( playlist[sum].m4v ); + player.media.load(); + player.play(); + playerData(playlist[sum].id,playlist[sum].title,playlist[sum].artist,playlist[sum].m4v,playlist[sum].thumbnail,playlist[sum].album,playlist[sum].country,playlist[sum].date,playlist[sum].gengre); + $('#player-play').hide(); + $('#player-pause').show(); + $('#main-player').attr('data-status','playing'); + duration(); + + }); + + $('.star').on('click', function(){ + + var len = $(this).attr('data-length'); + + $(this).parent().children('.star').each(function(){ + + var attr = $(this).attr('data-length'); + + if ( attr <= len ) { + + $(this).css('color','#292929'); + + } + else { + + $(this).css('color',''); + + } + + }); + + $(this).parent().attr('data-rate', len); + + playlist = []; + + $('.track').each(function(index){ + + $(this).children('.track-number').html(index + 1); + + playlist.push( + + { + + id: $(this).children('.track-number').text(), + title: $(this).children('.track-data').children('.track-title').text(), + artist: $(this).children('.track-data').children('.track-artist').text(), + m4v: $(this).attr('data-track-url'), + thumbnail: $(this).children('.track-thumbnail').children('img').attr('src'), + album: $(this).children('.track-detail').attr('data-track-album'), + country: $(this).children('.track-detail').attr('data-track-country'), + date: $(this).children('.track-detail').attr('data-track-date'), + gengre: $(this).children('.track-detail').attr('data-track-gengre'), + rate: $(this).children('.star-rating').attr('data-rate') + + } + + ); + + }); + + var listString = JSON.stringify(playlist); + + // STORAGE ARRAY TO LOCAL STORAGE SYSTEM OF BROWSER + localStorage.setItem("musiclist", listString); + + }); + + $('.track-delete').on('click', function(){ + + var id = $(this).parent().children('.track-number').text(); + var parID = parseInt(id); + $(this).parent().fadeOut().remove(); + var len = $('#tracks').children().length; + + if ( len > 0 ) { + + playlist = []; + + $('.track').each(function(index){ + + $(this).children('.track-number').html(index + 1); + + playlist.push( + + { + + id: $(this).children('.track-number').text(), + title: $(this).children('.track-data').children('.track-title').text(), + artist: $(this).children('.track-data').children('.track-artist').text(), + m4v: $(this).attr('data-track-url'), + thumbnail: $(this).children('.track-thumbnail').children('img').attr('src'), + album: $(this).children('.track-detail').attr('data-track-album'), + country: $(this).children('.track-detail').attr('data-track-country'), + date: $(this).children('.track-detail').attr('data-track-date'), + gengre: $(this).children('.track-detail').attr('data-track-gengre'), + rate: $(this).children('.star-rating').attr('data-rate') + + } + + ); + + }); + + var listString = JSON.stringify(playlist); + + // STORAGE ARRAY TO LOCAL STORAGE SYSTEM OF BROWSER + localStorage.setItem("musiclist", listString); + + } + else { + + localStorage.removeItem("musiclist"); + + } + + + }); + + // ON CLICK A SOCIAL MEDIA ICON + $('.popup').click(function (event) { + + event.preventDefault(); + window.open($(this).attr("href"), "popupWindow", "width=600,height=300,scrollbars=yes"); + + }); + + $('#add-track-label').on('click', function(){ + + $('#get-track-info').slideToggle(); + + }); + + $('#mep_0').css({ + 'position':'fixed', + 'top':'-1000px' + }); + + // FUNCTIONALITY + + // APPENDING DATA TO SPECIFIC HTML TAGS, RETRIEVING FROM TRACKS + function playerData(id,title,artist,url,thumbnail,album,country,date,gengre) { + + $('#main-player').attr('data-track-id',id); + $('#main-player').attr('data-track-url',url); + var uri = $('#main-player').attr('data-track-url'); + $('.player-track-title').html(title); + $('.player-track-artist').html(artist); + $('#google-plus').attr('href','https://plus.google.com/share?url='+uri); + $('#facebook').attr('href','https://www.facebook.com/sharer/sharer.php?u='+uri); + $('#twitter').attr('href','https://twitter.com/home?status='+uri); + $('#linkedin').attr('href','https://www.linkedin.com/shareArticle?mini=true&url='+uri); + $('#playing-track-thumbnail').html(''); + $(document).prop('title', artist+' - '+title); + $('#artist-name').html('Τραγουδιστής: '+artist); + $('#song-name').html('Τραγούδι: '+title); + $('#album').html('Αλμπουμ: '+album); + $('#country').html('Χώρα: '+country); + $('#release-date').html('Ημ.Κυκλοφορίας: '+date); + $('#genre').html('Είδος: '+gengre); + + } + + // GETTING THE DURATION AND CURRENT TIME OF EACH TRACK + function duration() { + + var interval = setInterval(function(){ + + var duration = $('.mejs-duration').text(); + var curTime = $('.mejs-currenttime').text(); + $('#duration-time').html( duration ); + $('#current-time').html( curTime ); + + }, 1000); + + } + + // UPDATING PLAYER PROGRESS BAR DEPEND ON EACH TRACK + function progress(player) { + + player.addEventListener('timeupdate', function(){ + + var curTime = player.currentTime; + var duration = player.duration; + var sum = curTime * 100 / duration; + var loaded = $('.mejs-time-loaded').attr('style').replace( /[^\d.]/g, '' ); + var num = loaded * 100 / 41; + $('#duration-bar-inner').css('width',sum+'%'); + $('#duration-bar-loaded').css('width',num+'%'); + + },false); + + } + + // AUTO PLAYING NEXT TRACK WHEN CURRENT ENDS + function changeTrack() { + + var interval = setInterval(function(){ + + var id = $('#main-player').attr('data-track-id'); + var num = parseInt(id); + var sum; + var next; + var status = $('#main-player').attr('data-status'); + var duration = $('#duration-time').text(); + var curTime = $('#current-time').text(); + var length = playlist.length - 1; + var shuffleStatus = $('#player-shuffle').attr('class'); + + $('.track-number').each(function(){ + + if ( $(this).text() == num+1 ) { + + next = $(this).parent().next().children('.track-number').text() - 1; + + } + + }); + + if ( shuffleStatus == 'shuffle-on' ) { + + sum = shufflePlay( length ); + + } + else { + + if ( next == -1 ) { + + sum = $('.track').first().children('.track-number').text() - 1; + + } + else { + + sum = next; + + } + + } + + if ( status == 'playing' && curTime >= '00:01' ) { + + if ( curTime >= duration ) { + + $('#main-player').attr('data-status','pausing'); + player.pause(); + player.setSrc( playlist[sum].m4v ); + player.media.load(); + player.play(); + playerData(playlist[sum].id,playlist[sum].title,playlist[sum].artist,playlist[sum].m4v,playlist[sum].thumbnail,playlist[sum].album,playlist[sum].country,playlist[sum].date,playlist[sum].gengre); + timeOut(); + + } + + } + + },1000); + + function timeOut() { + + setTimeout(function(){ $('#main-player').attr('data-status','playing'); }, 9000); + + } + + } + + // DRAG VOLUME AND PROGRESS ELEMENT AND THEN CHANGE VALUES DEPEND ON DRAGGING VALUE + function drag( elem, inner, vol, active ) { + + var clicking = false; + + + $(elem).mousedown(function(e) { + + clicking = true; + updatebar(e.pageX); + + }); + + $(document).mouseup(function(e) { + + clicking = false; + + }); + + $(elem).mousemove(function(e) { + + if ( clicking == false ) return; + + updatebar(e.pageX); + + }); + + + var updatebar = function(x) { + + var progress = $(elem); + var position = x - progress.offset().left; + var percentage = 100 * position / progress.width(); + + if(percentage > 100) { + + percentage = 100; + + } + + if(percentage < 0) { + + percentage = 0; + + } + + var decimal = percentage / 100; + var curTime = vol.currentTime; + var duration = vol.duration; + var sum = percentage * duration / 100; + + if ( active == 'volume' ) { + + vol.setVolume( decimal.toFixed(1) ); + $(inner).css('width', percentage+'%'); + + } + else { + + $(inner).css('width', percentage+'%'); + vol.setCurrentTime(sum); + + } + + }; + + } + + // GET CURRENT DATE AND TIME FROM BROWSER + function date() { + + var d = new Date(); + var date = d.getDate(); + var month = d.getMonth() + 1; + var year = d.getFullYear(); + var hours = d.getHours(); + var mins = d.getMinutes(); + var sec = d.getSeconds(); + if ( hours < 10 ) {hours = '0'+hours;} + if ( mins < 10 ) {mins = '0'+mins;} + if ( sec < 10 ) {sec = '0'+sec;} + $('#time-panel').html(' '+date+'/'+month+'/'+year+' - '+hours+':'+mins+':'+sec); + + } + + function shufflePlay(max) { + + var playerId = $('#main-player').attr('data-track-id'); + var random = Math.floor(Math.random()*(max-0+1)+0); + + if ( random == playerId ) { + + random = Math.floor(Math.random()*(max-0+1)+0); + + } + + return random; + + } + + $('#sort-inner').on('click', function(){ + + var attr = $(this).attr('class'); + + if ( attr == 'ascending' ) { + + $(this).addClass('descending'); + $(this).removeClass('ascending'); + $(this).children('span').html(''); + + $('.track > .star-rating').sort(function(a,b){ + + return $(a).data('rate') > $(b).data('rate') + + }).each(function(){ + + $(this).parent().remove().appendTo('#tracks'); + + }); + + } + if ( attr == 'descending' ) { + + $(this).addClass('ascending'); + $(this).removeClass('descending'); + $(this).children('span').html(''); + + $('.track > .star-rating').sort(function(a,b){ + + return $(a).data('rate') < $(b).data('rate') + + }).each(function(){ + + $(this).parent().remove().appendTo('#tracks'); + + }); + + } + + }); + + var interval = setInterval(function(){date();},1000); + + changeTrack(); + +}); \ No newline at end of file diff --git a/YouTube plug-in/js/jplayer-library.min.js b/YouTube plug-in/js/jplayer-library.min.js new file mode 100644 index 00000000..1629d0fd --- /dev/null +++ b/YouTube plug-in/js/jplayer-library.min.js @@ -0,0 +1,148 @@ +/*! +* MediaElement.js +* HTML5