Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Get some playlist info (Requested by Arnie)

ExtremeHunter Jun 14th, 2012 311 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==PREPROCESSOR==
  2. // @name "Get some playlist info (15.June.2012)"
  3. // @author "ExtremeHunter"
  4. // ==/PREPROCESSOR==
  5. function RGB(r, g, b) {
  6.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  7. }
  8.  
  9. (function getPlaylistInfo() {
  10.  
  11.     activePlaylist = plman.ActivePlaylist;
  12.     getPlaylistItems = plman.GetPlaylistItems(activePlaylist);
  13.     playlistItemCount = plman.PlaylistItemCount(activePlaylist);
  14.     seconds = 0;
  15.     sizeInBytes = 0;
  16.     timeFormat = function (s) {
  17.  
  18.         var weeks = Math.floor(s / 604800),
  19.             days = Math.floor(s % 604800 / 86400),
  20.             hours = Math.floor((s % 86400) / 3600),
  21.             minutes = Math.floor(((s % 86400) % 3600) / 60),
  22.             seconds = (((s % 86400) % 3600) % 60).toFixed(0),
  23.             weeks = weeks > 0 ? weeks + "wk " : "",
  24.             days = days > 0 ? days + "d " : "",
  25.             hours = hours > 0 ? hours + ":" : "",
  26.             minutes = (minutes < 10 ? "0" + minutes : minutes) + ":",
  27.             seconds = seconds < 10 ? "0" + seconds : seconds;
  28.  
  29.         return weeks + days + hours + minutes + seconds;
  30.  
  31.     }
  32.  
  33.     var tempFileName;
  34.     for (var i = 0, l = playlistItemCount; i != l; i++) {
  35.  
  36.         seconds += parseFloat(fb.TitleFormat("%length_seconds_fp%").EvalWithMetadb(getPlaylistItems.Item(i)));
  37.         fileName = fb.TitleFormat("$filename(%_path%).$ext(%_path%)").EvalWithMetadb(getPlaylistItems.Item(i));
  38.         if (fileName != tempFileName) {
  39.             sizeInBytes += Math.floor(fb.TitleFormat("%filesize%").EvalWithMetadb(getPlaylistItems.Item(i)));
  40.         }
  41.         tempFileName = fileName;
  42.     }
  43.  
  44.     var sizeInMB = sizeInBytes / 1048576;
  45.     var sizeInGB = sizeInBytes / 1073741824;
  46.  
  47.     if (sizeInMB < 1024) size = Math.floor(sizeInMB) + " MB";
  48.     else size = Math.floor(100 * sizeInGB) / 100 + " GB";
  49.    
  50.     window.Repaint();
  51.  
  52. })();
  53.  
  54. function on_paint(gr) {
  55.     gr.GdiDrawText("Playlist name: " + plman.GetPlaylistName(activePlaylist) + "\n" + playlistItemCount + " Items" + (sizeInBytes ? "\nTotal time: " + timeFormat(seconds) + "\nSize: " + size : ""), gdi.font("Segoe Ui", 24, 0), RGB(0, 0, 0), 20, 20, 1000, 500, 0x00000004);
  56. }
  57.  
  58. function on_playlist_switch() {
  59.     getPlaylistInfo();
  60. }
  61.  
  62. function on_playlist_items_added(playlist) {
  63.     getPlaylistInfo();
  64. }
  65.  
  66. function on_playlist_items_removed(playlist, new_count) {
  67.     getPlaylistInfo();
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top