Advertisement
Katting

iPawd Music Player - JS

Jun 1st, 2017
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. <script>
  2. $(document).ready(function() {
  3.  
  4. var myPlaylist = new jPlayerPlaylist({
  5. jPlayer: "#jquery_jplayer_1",
  6. cssSelectorAncestor: "#jp_container_1"
  7. }, [{
  8. image: "<img src='http://s.mxmcdn.net/images-storage/albums/3/2/6/9/1/8/30819623_800_800.jpg'>",
  9. title: "Bodypop",
  10. artist: "Ken Water / Blogilates ft. TJ Carter",
  11. mp3: "https://dl.dropboxusercontent.com/s/17ymg2fzjnxpll0/Ken%20WatersBlogilates%20-%20BODYPOP%20%28ft.%20TJ%20Carter%29%20%28Lyrics%29%20%5BHD%5D.mp3?dl=0"
  12. },
  13.  
  14. {
  15. image: "<img src='https://i1.sndcdn.com/artworks-000175351027-r5z2ph-t500x500.jpg'>",
  16. title: "Nice Swing",
  17. artist: "Ken Waters",
  18. mp3: "https://dl.dropboxusercontent.com/s/0npsctl29ym7g5j/Ken%20Waters%20-%20Nice%20Swing.mp3?dl=0"
  19. },
  20.  
  21. {
  22. image:"<img src='https://f4.bcbits.com/img/a3258123251_10.jpg'>",
  23. title:"Dreams",
  24. artist:"Ken Waters ft. TJ Carter",
  25. mp3:"https://dl.dropboxusercontent.com/s/s8pyh8z0nqoqyhe/Ken%20Waters%20-%20Dreams%20ft.%20TJ%20Carter.mp3?dl=0"
  26. },
  27.  
  28.  
  29. {
  30. image:"<img src='http://clubtone.net/_ld/4361/436145.jpg'>",
  31. title:"XOXO",
  32. artist:"Ken Waters",
  33. mp3:"https://dl.dropboxusercontent.com/s/ymtepigt5p15ko3/Ken%20Waters%20-%20XOXO.mp3?dl=0"
  34. },
  35.  
  36. {
  37. image:"<img src='https://f4.bcbits.com/img/a3258123251_10.jpg'>",
  38. title:"Go",
  39. artist:"Ken Waters ft. TJ Carter",
  40. mp3:"https://dl.dropboxusercontent.com/s/jt1ta2j07077o20/Ken%20Waters%20-%20Go%20ft.%20TJ%20Carter.mp3?dl=0"
  41. }],
  42.  
  43. {
  44. swfPath: "../../dist/jplayer",
  45. supplied: "mp3",
  46. wmode: "window",
  47. useStateClassSkin: true,
  48. autoBlur: false,
  49. smoothPlayBar: true,
  50. keyEnabled: true
  51. }); // end jplayer initiate
  52.  
  53. /* ======== Other Audio Player Functions ======== */
  54.  
  55. $("#jquery_jplayer_1").on(
  56. $.jPlayer.event.ready + ' ' + $.jPlayer.event.play,
  57. function(event) {
  58.  
  59. /* === ENABLE PLAYLIST ==== */
  60.  
  61. var current = myPlaylist.current;
  62. var playlist = myPlaylist.playlist;
  63. $.each(playlist, function(index, obj) {
  64. if (index == current) {
  65. $(".jp-now-playing-art").html("<div class='jp-image'>" + obj.image + "</div>");
  66. $(".jp-now-playing").html("<div class='jp-track-name'>" + obj.title + "</div> <div class='jp-artist-name'>" + obj.artist + "</div>");
  67.  
  68. }
  69. });
  70.  
  71. /* === VOLUME DRAGGING ==== */
  72.  
  73. $('.jp-volume-bar').mousedown(function() {
  74. var parentOffset = $(this).offset(),
  75. width = $(this).width();
  76. $(window).mousemove(function(e) {
  77. var x = e.pageX - parentOffset.left,
  78. volume = x / width
  79. if (volume > 1) {
  80. $("#jquery_jplayer_1").jPlayer("volume", 1);
  81. } else if (volume <= 0) {
  82. $("#jquery_jplayer_1").jPlayer("mute");
  83. } else {
  84. $("#jquery_jplayer_1").jPlayer("volume", volume);
  85. $("#jquery_jplayer_1").jPlayer("unmute");
  86. }
  87. });
  88. return false;
  89. })
  90. .mouseup(function() {
  91. $(window).unbind("mousemove");
  92. });
  93.  
  94. /* === ENABLE DRAGGING ==== */
  95.  
  96. var timeDrag = false; /* Drag status */
  97. $('.jp-play-bar').mousedown(function(e) {
  98. timeDrag = true;
  99. updatebar(e.pageX);
  100. });
  101. $(document).mouseup(function(e) {
  102. if (timeDrag) {
  103. timeDrag = false;
  104. updatebar(e.pageX);
  105. }
  106. });
  107. $(document).mousemove(function(e) {
  108. if (timeDrag) {
  109. updatebar(e.pageX);
  110. }
  111. });
  112.  
  113. //update Progress Bar control
  114. var updatebar = function(x) {
  115.  
  116. var progress = $('.jp-progress');
  117. //var maxduration = myPlaylist.duration; //audio duration
  118.  
  119. var position = x - progress.offset().left; //Click pos
  120. var percentage = 100 * position / progress.width();
  121.  
  122. //Check within range
  123. if (percentage > 100) {
  124. percentage = 100;
  125. }
  126. if (percentage < 0) {
  127. percentage = 0;
  128. }
  129.  
  130. $("#jquery_jplayer_1").jPlayer("playHead", percentage);
  131.  
  132. //Update progress bar
  133. $('.jp-play-bar').css('width', percentage + '%');
  134. };
  135.  
  136. }); // end jplayer event ready
  137.  
  138. }); // end document ready
  139. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement