| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html i18n-values="dir:textdirection;"> | 2 <html i18n-values="dir:textdirection;"> |
| 3 <head> | 3 <head> |
| 4 <meta charset="utf-8"> | 4 <meta charset="utf-8"> |
| 5 <title>Media Playlist</title> | 5 <title>Media Playlist</title> |
| 6 <style type="text/css"> | 6 <style type="text/css"> |
| 7 body { | 7 body { |
| 8 background: #080809; | 8 background: #080809; |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 text-decoration: line-through; | 45 text-decoration: line-through; |
| 46 } | 46 } |
| 47 | 47 |
| 48 .error { | 48 .error { |
| 49 color: red; | 49 color: red; |
| 50 float: left; | 50 float: left; |
| 51 padding-right: 5px; | 51 padding-right: 5px; |
| 52 } | 52 } |
| 53 | 53 |
| 54 </style> | 54 </style> |
| 55 <script src="shared/js/local_strings.js"></script> | 55 <script src="chrome://resources/js/local_strings.js"></script> |
| 56 <script> | 56 <script> |
| 57 | 57 |
| 58 function $(o) { | 58 function $(o) { |
| 59 return document.getElementById(o); | 59 return document.getElementById(o); |
| 60 } | 60 } |
| 61 | 61 |
| 62 function pathIsVideoFile(path) { | 62 function pathIsVideoFile(path) { |
| 63 return /\.(mp4|ogg|mpg|avi)$/i.test(path); | 63 return /\.(mp4|ogg|mpg|avi)$/i.test(path); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 function pathIsAudioFile(path) { | 66 function pathIsAudioFile(path) { |
| 67 return /\.(mp3|m4a)$/i.test(path); | 67 return /\.(mp3|m4a)$/i.test(path); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 /////////////////////////////////////////////////////////////////////////////// | 70 /////////////////////////////////////////////////////////////////////////////// |
| 71 // Document Functions: | 71 // Document Functions: |
| 72 /** | 72 /** |
| 73 * Window onload handler, sets up the page. | 73 * Window onload handler, sets up the page. |
| 74 */ | 74 */ |
| 75 | 75 |
| 76 var currentPlaylist = null; | 76 var currentPlaylist = null; |
| 77 var currentOffset = -1; | 77 var currentOffset = -1; |
| 78 function load() { | 78 function load() { |
| 79 document.body.addEventListener('dragover', function(e) { | 79 document.body.addEventListener('dragover', function(e) { |
| 80 if (e.preventDefault) e.preventDefault(); | 80 if (e.preventDefault) e.preventDefault(); |
| 81 }); | 81 }); |
| 82 document.body.addEventListener('drop', function(e) { | 82 document.body.addEventListener('drop', function(e) { |
| 83 if (e.preventDefault) e.preventDefault(); | 83 if (e.preventDefault) e.preventDefault(); |
| 84 }); | 84 }); |
| 85 chrome.send("getCurrentPlaylist", []); | 85 chrome.mediaPlayerPrivate.getPlaylist(getPlaylistCallback); |
| 86 chrome.mediaPlayerPrivate.onPlaylistChanged.addListener(function() { |
| 87 chrome.mediaPlayerPrivate.getPlaylist(getPlaylistCallback); |
| 88 }); |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 function getDisplayNameFromPath(path) { | 91 function getDisplayNameFromPath(path) { |
| 89 slash = path.lastIndexOf("/") | 92 slash = path.lastIndexOf("/") |
| 90 if (slash != -1) { | 93 if (slash != -1) { |
| 91 fileName = path.substring(slash+1,path.length) | 94 fileName = path.substring(slash+1,path.length) |
| 92 return fileName; | 95 return fileName; |
| 93 } else { | 96 } else { |
| 94 return path; | 97 return path; |
| 95 } | 98 } |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 function setPlaylistOffset(offset) { | 101 function setPlaylistOffset(offset) { |
| 99 chrome.send("setCurrentPlaylistOffset", ['' + offset]); | 102 chrome.mediaPlayerPrivate.setPlaylistPosition(offset); |
| 100 }; | 103 }; |
| 101 | 104 |
| 102 function updateUI() { | 105 function updateUI() { |
| 103 var main = $('main'); | 106 var main = $('main'); |
| 104 if (currentPlaylist) { | 107 if (currentPlaylist) { |
| 105 main.innerHTML = ''; | 108 main.innerHTML = ''; |
| 106 var main = $('main'); | 109 var main = $('main'); |
| 107 for (var x = 0; x < currentPlaylist.length; x++) { | 110 for (var x = 0; x < currentPlaylist.length; x++) { |
| 108 var rowdiv = document.createElement('div'); | 111 var rowdiv = document.createElement('div'); |
| 109 rowdiv.className = 'playlistitem'; | 112 rowdiv.className = 'playlistitem'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 132 rowdiv.appendChild(titlediv); | 135 rowdiv.appendChild(titlediv); |
| 133 rowdiv.onclick = new Function('setPlaylistOffset(' + x + ')'); | 136 rowdiv.onclick = new Function('setPlaylistOffset(' + x + ')'); |
| 134 if (currentOffset == x) { | 137 if (currentOffset == x) { |
| 135 rowdiv.className = 'playlistitem playing'; | 138 rowdiv.className = 'playlistitem playing'; |
| 136 } | 139 } |
| 137 main.appendChild(rowdiv); | 140 main.appendChild(rowdiv); |
| 138 } | 141 } |
| 139 } | 142 } |
| 140 }; | 143 }; |
| 141 | 144 |
| 142 function playlistChanged(info, playlist) { | 145 function getPlaylistCallback(playlist) { |
| 143 currentPlaylist = playlist; | 146 currentPlaylist = playlist.items; |
| 144 currentOffset = info.currentOffset; | 147 currentOffset = playlist.position; |
| 145 updateUI(); | 148 updateUI(); |
| 146 }; | 149 }; |
| 147 </script> | 150 </script> |
| 148 <body onload='load();' onselectstart='return false'> | 151 <body onload='load();' onselectstart='return false'> |
| 149 <div id='main' class='playlist'> | 152 <div id='main' class='playlist'> |
| 150 </div> | 153 </div> |
| 151 </body> | 154 </body> |
| 152 </html> | 155 </html> |
| OLD | NEW |