vendor: 13,269 bytes, lines 1-384
1(function webpackUniversalModuleDefinition(root, factory) { 2 if(typeof exports === 'object' && typeof module === 'object') 3 module.exports = factory(); 4 else if(typeof define === 'function' && define.amd) 5 define("Amplitude", [], factory); 6 else if(typeof exports === 'object') 7 exports["Amplitude"] = factory(); 8 else 9 root["Amplitude"] = factory(); 10})(this, function() { 11return /******/ (function(modules) { // webpackBootstrap 12/******/ // The module cache 13/******/ var installedModules = {}; 14/******/ 15/******/ // The require function 16/******/ function __webpack_require__(moduleId) { 17/******/ 18/******/ // Check if module is in cache 19/******/ if(installedModules[moduleId]) { 20/******/ return installedModules[moduleId].exports; 21/******/ } 22/******/ // Create a new module (and put it into the cache) 23/******/ var module = installedModules[moduleId] = { 24/******/ i: moduleId, 25/******/ l: false, 26/******/ exports: {} 27/******/ }; 28/******/ 29/******/ // Execute the module function 30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31/******/ 32/******/ // Flag the module as loaded 33/******/ module.l = true; 34/******/ 35/******/ // Return the exports of the module 36/******/ return module.exports; 37/******/ } 38/******/ 39/******/ 40/******/ // expose the modules object (__webpack_modules__) 41/******/ __webpack_require__.m = modules; 42/******/ 43/******/ // expose the module cache 44/******/ __webpack_require__.c = installedModules; 45/******/ 46/******/ // identity function for calling harmony imports with the correct context 47/******/ __webpack_require__.i = function(value) { return value; }; 48/******/ 49/******/ // define getter function for harmony exports 50/******/ __webpack_require__.d = function(exports, name, getter) { 51/******/ if(!__webpack_require__.o(exports, name)) { 52/******/ Object.defineProperty(exports, name, { 53/******/ configurable: false, 54/******/ enumerable: true, 55/******/ get: getter 56/******/ }); 57/******/ } 58/******/ }; 59/******/ 60/******/ // getDefaultExport function for compatibility with non-harmony modules 61/******/ __webpack_require__.n = function(module) { 62/******/ var getter = module && module.__esModule ? 63/******/ function getDefault() { return module['default']; } : 64/******/ function getModuleExports() { return module; }; 65/******/ __webpack_require__.d(getter, 'a', getter); 66/******/ return getter; 67/******/ }; 68/******/ 69/******/ // Object.prototype.hasOwnProperty.call 70/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 71/******/ 72/******/ // __webpack_public_path__ 73/******/ __webpack_require__.p = ""; 74/******/ 75/******/ // Load entry module and return exports 76/******/ return __webpack_require__(__webpack_require__.s = 47); 77/******/ }) 78/************************************************************************/ 79/******/ ([ 80/* 0 */ 81/***/ (function(module, exports, __webpack_require__) { 82 83"use strict"; 84 85 86var _package = __webpack_require__(59); 87 88module.exports = { 89 version: _package.version, 90 91 audio: new Audio(), 92 93 active_metadata: {}, 94 95 active_album: "", 96 97 active_index: 0, 98 99 active_playlist: null, 100 101 playback_speed: 1.0, 102 103 callbacks: {}, 104 105 songs: [], 106 107 playlists: {}, 108 109 start_song: "", 110 111 starting_playlist: "", 112 113 starting_playlist_song: "", 114 115 repeat: false, 116 117 repeat_song: false, 118 119 shuffle_list: {}, 120 121 shuffle_on: false, 122 123 default_album_art: "", 124 125 default_playlist_art: "", 126 127 debug: false, 128 129 volume: 0.5, 130 131 pre_mute_volume: 0.5, 132 133 volume_increment: 5, 134 135 volume_decrement: 5, 136 137 soundcloud_client: "", 138 139 soundcloud_use_art: false, 140 141 soundcloud_song_count: 0, 142 143 soundcloud_songs_ready: 0, 144 145 is_touch_moving: false, 146 147 buffered: 0, 148 149 bindings: {}, 150 151 continue_next: true, 152 153 delay: 0, 154 155 player_state: "stopped", 156 157 web_audio_api_available: false, 158 159 context: null, 160 161 source: null, 162 163 analyser: null, 164 165 visualizations: { 166 available: [], 167 168 active: [], 169 170 backup: "" 171 }, 172 173 waveforms: { 174 sample_rate: 100, 175 176 built: [] 177 } 178}; /** 179 * These variables make Amplitude run. The config is the most important 180 * containing active settings and parameters. 181 * 182 * The config JSON is the global settings for ALL of Amplitude functions. 183 * This is global and contains all of the user preferences. The default 184 * settings are set, and the user overwrites them when they initialize 185 * Amplitude. 186 * 187 * @module config 188 * @type {object} 189 * @property {string} config.version - The current version of AmplitudeJS. 190 * @property {object} config.audio - Handles all of the audio. 191 * @property {object} config.active_metadata - Contains the active metadata for the song. 192 * @property {string} config.active_album - Holds the active album name. Used to check and see if the album changed and run the album changed callback. 193 * @property {number} config.active_index - Contains the index of the actively playing song. 194 * @property {string} config.active_playlist - Contains the key to the active playlist index. 195 * @property {number} config.playback_speed - Sets the initial playback speed of the song. The values for this can be 1.0, 1.5, 2.0 196 * @property {object} config.callbacks - The user can pass a JSON object with a key => value store of callbacks to be run at certain events. 197 * @property {array} config.songs - Contains all of the songs the user has passed to Amplitude to use. 198 * @property {object} config.playlists - Contains all of the playlists the user created. 199 * @property {object} config.start_song - The index of the song that AmplitudeJS should start with. 200 * @property {string} config.starting_playlist - The starting playlist the player will intiialize to. 201 * @property {string} config.starting_playlist_song - The index of the song in the playlist that should be started. 202 * @property {boolean} config.repeat - When repeat is on, when the song ends the song will replay itself. 203 * @property {object} config.shuffle_list - When shuffled, gets populated with the songs the user provided in a random order. 204 * @property {boolean} config.shuffle_on - When on, gets set to true so when traversing through songs, AmplitudeJS knows whether or not to use the songs object or the shuffle_list 205 * @property {string} config.default_album_art - The user can set default album art to be displayed if the song they set doesn't contain album art. 206 * @property {string} config.default_playlist_art - The user can set default playlist art to be displayed if the playlist they are setting meta data for doesn't contain an art picture. 207 * @property {boolean} config.debug - When set to true, AmplitudeJS will print to the console any errors providing helpful feedback to the user. 208 * @property {number} config.volume - The user can set the initial volume to a number between 0 and 1 over-riding the default of .5 209 * @property {number} config.pre_mute_volume - This is set on mute so that when a user un-mutes AmplitudeJS knows what to restore the volume to. 210 * @property {number} config.volume_increment - The default values are an integer between 1 and 100 for how much the volume should increase when the user presses the volume up button. 211 * @property {number} config.volume_decrement - The default values are an integer between 1 and 100 for how much the volume should decrease when the user presses the volume down button. 212 * @property {string} config.soundcloud_client - When using SoundCloud, the user will have to provide their API Client ID 213 * @property {boolean} config.soundcloud_use_art - The user can set this to true and AmplitudeJS will use the album art for the song returned from the Soundcloud API 214 * @property {number} config.soundcloud_song_count - Used on config to count how many songs are from Soundcloud and compare it to how many are ready for when to move to the rest of the configuration 215 * @property {number} config.soundcloud_songs_ready - Used on config to count how many songs are ready so when we get all of the data from the SoundCloud API that we need this should match the SoundCloud song count meaning we can move to the rest of the config. 216 * @property {integer} config.is_touch_moving - Flag for if the user is moving the screen. 217 * @property {boolean} config.buffered - How much of the song is buffered. 218 * @property {object} config.bindings - Array of bindings to certain key events. 219 * @property {boolean} config.continue_next - Determines when a song ends, we should continue to the next song. 220 * @property {number} config.delay - Sets the delay between songs in MS. 221 * @property {boolean} config.use_web_audio_api - Flag that determines if the user wants to use Web Audio API Components. 222 * @property {boolean} config.web_audio_api_available - Flag that determines if the Web Audio API is available. 223 * @property {object} config.context - Web Audio API Context 224 * @property {object} config.source - Web Audio API Source 225 * @property {object} config.analyser - Web Audio API Analyser 226 * @property {string} config.player_state - The current state of the player. 227 */ 228 229/***/ }), 230/* 1 */ 231/***/ (function(module, exports, __webpack_require__) { 232 233"use strict"; 234 235 236Object.defineProperty(exports, "__esModule", { 237 value: true 238}); 239 240var _config = __webpack_require__(0); 241 242var _config2 = _interopRequireDefault(_config); 243 244var _checks = __webpack_require__(5); 245 246var _checks2 = _interopRequireDefault(_checks); 247 248var _audioNavigation = __webpack_require__(3); 249 250var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 251 252var _playPauseElements = __webpack_require__(2); 253 254var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 255 256var _metaDataElements = __webpack_require__(7); 257 258var _metaDataElements2 = _interopRequireDefault(_metaDataElements); 259 260var _callbacks = __webpack_require__(9); 261 262var _callbacks2 = _interopRequireDefault(_callbacks); 263 264var _debug = __webpack_require__(4); 265 266var _debug2 = _interopRequireDefault(_debug); 267 268var _visualizations = __webpack_require__(16); 269 270var _visualizations2 = _interopRequireDefault(_visualizations); 271 272var _configState = __webpack_require__(6); 273 274var _configState2 = _interopRequireDefault(_configState); 275 276function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 277 278/** 279 * Interacts directly with native functions of the Audio element. Logic 280 * leading up to these methods are handled by click handlers which call 281 * helpers and visual synchronizers. These are the core functions of AmplitudeJS. 282 * Every other function that leads to these prepare the information to be 283 * acted upon by these functions. 284 * 285 * @module core/Core 286 */ 287 288 289/** 290 * Import the Visualizations from the FX module. 291 * @module fx/visualizations 292 */ 293 294 295/** 296 * Imports AmplitudeJS Callback Utility 297 * @module utilities/callbacks 298 */ 299 300 301/** 302 * Imports the Play/Pause Visual Elements module. 303 * @module visual/playPauseElements 304 */ 305 306 307/** 308 * Imports the Checks module. 309 * @module utilities/checks 310 */ 311var Core = function () { 312 /** 313 * Plays the active song. If the current song is live, it reconnects 314 * the stream before playing. 315 * 316 * Public Accessor: Amplitude.play() 317 * 318 * @access public 319 */ 320 function play() { 321 _visualizations2.default.stop(); 322 _visualizations2.default.run(); 323 324 /* 325 If the audio is live we re-conenct the stream. 326 */ 327 if (_config2.default.active_metadata.live) { 328 reconnectStream(); 329 } 330 331 /* 332 Mobile remote sources need to be reconnected on play. I think this is 333 because mobile browsers are optimized not to load all resources 334 for speed reasons. We only do this if mobile and the paused button 335 is not clicked. If the pause button was clicked then we don't reconnect 336 or the user will lose their place in the stream. 337 */ 338 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && !_config2.default.paused) { 339 reconnectStream(); 340 } 341 342 /* 343 Play the song and set the playback rate to the playback 344 speed. 345 */ 346 var playPromise = _config2.default.audio.play(); 347 348 if (playPromise !== undefined) { 349 playPromise.then(function (_) {}).catch(function (error) {}); 350 } 351 _config2.default.audio.play(); 352 _config2.default.audio.playbackRate = _config2.default.playback_speed; 353 354 /* 355 Sets the state of the player. 356 */ 357 _configState2.default.setPlayerState(); 358 } 359 360 /** 361 * Pauses the active song. If it's live, it disconnects the stream. 362 * 363 * Public Accessor: Amplitude.pause() 364 * 365 * @access public 366 */ 367 function pause() { 368 _visualizations2.default.stop(); 369 370 /* 371 Pause the active song. 372 */ 373 _config2.default.audio.pause(); 374 375 /* 376 Flag that pause button was clicked. 377 */ 378 _config2.default.paused = true; 379 380 /* 381 If the song is live, we disconnect the stream so we aren't 382 saving it to memory. 383 */ 384
vendor: 4,101 bytes, lines 384-528
384console.log("_config2.default.active_metadata.live: ", _config2.default.active_metadata.live); 385 if (_config2.default.active_metadata.live) { 386 disconnectStream(); 387 } 388 389 /* 390 Sets the state of the player. 391 */ 392 _configState2.default.setPlayerState(); 393 } 394 395 /** 396 * Stops the active song by setting the current song time to 0. 397 * When the user resumes, it will be from the beginning. 398 * If it's a live stream it disconnects. 399 * 400 * Public Accessor: Amplitude.stop() 401 * 402 * @access public 403 */ 404 function stop() { 405 _visualizations2.default.stop(); 406 407 /* 408 Set the current time of the song to 0 which will reset the song. 409 */ 410 if (_config2.default.audio.currentTime != 0) { 411 _config2.default.audio.currentTime = 0; 412 } 413 414 /* 415 Run pause so the song will stop 416 */ 417 _config2.default.audio.pause(); 418 419 /* 420 If the song is live, disconnect the stream. 421 */ 422 if (_config2.default.active_metadata.live) { 423 disconnectStream(); 424 } 425 426 /* 427 Sets the state of the player. 428 */ 429 _configState2.default.setPlayerState(); 430 431 /* 432 Run the stop callback 433 */ 434 _callbacks2.default.run("stop"); 435 } 436 437 /** 438 * Sets the song volume. 439 * 440 * Public Accessor: Amplitude.setVolume( volumeLevel ) 441 * 442 * @access public 443 * @param {number} volumeLevel - A number between 1 and 100 as a percentage of 444 * min to max for a volume level. 445 */ 446 function setVolume(volumeLevel) { 447 /* 448 If the volume is set to mute somewhere else, we sync the display. 449 */ 450 if (volumeLevel == 0) { 451 _config2.default.audio.muted = true; 452 } else { 453 _config2.default.audio.muted = false; 454 } 455 456 /* 457 Sets the volume in the config so we can reference it later on. 458 */ 459 _config2.default.volume = volumeLevel; 460 461 /* 462 Set the volume of the active song. 463 */ 464 _config2.default.audio.volume = volumeLevel / 100; 465 } 466 467 /** 468 * Sets the song percentage. If it's a live song, we ignore this because 469 * we can't skip ahead. This is an issue if you have a playlist with 470 * a live source. 471 * 472 * Public Accessor: Amplitude.setSongLocation( songPercentage ) 473 * 474 * @access public 475 * @param {number} songPercentage - A number between 1 and 100 as a percentage of song completion. 476 */ 477 function setSongLocation(songPercentage) { 478 /* 479 As long as the song is not live, we can set the current time of the 480 song to the percentage the user passed in. 481 */ 482 if (!_config2.default.active_metadata.live) { 483 _config2.default.audio.currentTime = _config2.default.audio.duration * (songPercentage / 100); 484 } 485 } 486 487 /** 488 * Skips to a location in a song 489 * 490 * Public Accessor: Amplitude.skipToLocation( seconds ) 491 * 492 * @access public 493 * @param {number} seconds - An integer containing the seconds to skip to 494 */ 495 function skipToLocation(seconds) { 496 /* 497 When the active song can be played through, we can check to 498 see if the seconds will work. We only bind the event handler 499 once and remove it once it's fired. 500 */ 501 _config2.default.audio.addEventListener("canplaythrough", function () { 502 /* 503 If the active song duration is greater than or equal to the 504 amount of seconds the user wants to skip to and the seconds 505 is greater than 0, we skip to the seconds defined. 506 */ 507 if (_config2.default.audio.duration >= seconds && seconds > 0) { 508 _config2.default.audio.currentTime = seconds; 509 } else { 510 _debug2.default.writeMessage("Amplitude can't skip to a location greater than the duration of the audio or less than 0"); 511 } 512 }, { once: true }); 513 } 514 515 /** 516 * Disconnects the live stream 517 * 518 * Public Accessor: Amplitude.disconnectStream() 519 * 520 * @access public 521 */ 522 function disconnectStream() { 523 console.log("disconnectStream function called..."); 524 console.log("src1: ", _config2.default.audio.src); 525 _config2.default.audio.src = ""; 526 console.log("src2: ", _config2.default.audio.src); 527 _config2.default.audio.load(); 528 console.log("src3: ", _config2.default.audio.src);
vendor: 364,970 bytes, lines 529-13430
529 530 } 531 532 /** 533 * Reconnects the live stream 534 * 535 * Public Accessor: Amplitude.reconnectStream() 536 * 537 * @access public\ 538 */ 539 function reconnectStream() { 540 _config2.default.audio.src = _config2.default.active_metadata.url; 541 _config2.default.audio.load(); 542 } 543 544 /** 545 * Sets the playback speed for the song. 546 * 547 * @param {number} playbackSpeed The speed we want the song to play back at. 548 */ 549 function setPlaybackSpeed(playbackSpeed) { 550 /* 551 Set the config playback speed. 552 */ 553 _config2.default.playback_speed = playbackSpeed; 554 555 /* 556 Set the active song playback rate. 557 */ 558 _config2.default.audio.playbackRate = _config2.default.playback_speed; 559 } 560 561 /* 562 Return publically facing functions 563 */ 564 return { 565 play: play, 566 pause: pause, 567 stop: stop, 568 setVolume: setVolume, 569 setSongLocation: setSongLocation, 570 skipToLocation: skipToLocation, 571 disconnectStream: disconnectStream, 572 reconnectStream: reconnectStream, 573 setPlaybackSpeed: setPlaybackSpeed 574 }; 575}(); 576 577/** 578 * Import the Config State module. 579 * @module utilities/configState 580 */ 581 582 583/** 584 * Imports AmplitudeJS Debug Utility 585 * @module utilities/debug 586 */ 587 588 589/** 590 * Imports the Meta Data Visual Elements module. 591 * @module visual/metaDataElements 592 */ 593 594 595/** 596 * Imports the Audio Navigation module. 597 * @module utilities/audioNavigation 598 */ 599/** 600 * Imports the config module 601 * @module config 602 */ 603exports.default = Core; 604module.exports = exports["default"]; 605 606/***/ }), 607/* 2 */ 608/***/ (function(module, exports, __webpack_require__) { 609 610"use strict"; 611 612 613Object.defineProperty(exports, "__esModule", { 614 value: true 615}); 616 617var _config = __webpack_require__(0); 618 619var _config2 = _interopRequireDefault(_config); 620 621function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 622 623/** 624 * Defines the visual representation of AmplitudeJS play pause elements. 625 * @module visual/PlayPauseElements 626 */ 627var PlayPauseElements = function () { 628 /** 629 * Syncs all play pause elements. 630 * 631 * @access public 632 */ 633 function sync() { 634 syncGlobal(); 635 syncPlaylist(); 636 syncSong(); 637 syncSongInPlaylist(); 638 } 639 640 /** 641 * Syncs the global play pause buttons to the state of the active song. 642 * 643 * @access public 644 */ 645 function syncGlobal() { 646 /* 647 Get the active song state. 648 */ 649 var state = _config2.default.audio.paused ? "paused" : "playing"; 650 651 /* 652 Get all play pause buttons. 653 */ 654 var playPauseElements = document.querySelectorAll(".amplitude-play-pause"); 655 656 /* 657 Iterate over all of the play pause elements syncing the 658 display visually. 659 */ 660 for (var i = 0; i < playPauseElements.length; i++) { 661 /* 662 Grab the playlist and song attributes from the element. 663 */ 664 var playlist = playPauseElements[i].getAttribute("data-amplitude-playlist"); 665 var song = playPauseElements[i].getAttribute("data-amplitude-song-index"); 666 667 /* 668 This method is responsible for only the global elements, 669 so we make sure there are no playlist or songs defined on 670 the element. 671 */ 672 if (playlist == null && song == null) { 673 /* 674 Determines what classes we should add and remove 675 from the elements. 676 */ 677 switch (state) { 678 case "playing": 679 setElementPlay(playPauseElements[i]); 680 break; 681 case "paused": 682 setElementPause(playPauseElements[i]); 683 break; 684 } 685 } 686 } 687 } 688 689 /** 690 * Syncs the main playlist play pause buttons to the state of the active song. 691 * 692 * @access public 693 */ 694 function syncPlaylist() { 695 var state = _config2.default.audio.paused ? "paused" : "playing"; 696 697 /* 698 Get all of the main playlist play pause elements 699 */ 700 var playlistPlayPauseElements = document.querySelectorAll('.amplitude-play-pause[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 701 702 /* 703 Iterate over the play pause elements, syncing the state accordingly. 704 */ 705 for (var i = 0; i < playlistPlayPauseElements.length; i++) { 706 /* 707 Grab the song attributes from the element. 708 */ 709 var song = playlistPlayPauseElements[i].getAttribute("data-amplitude-song-index"); 710 711 /* 712 We want only the play pause elements for the main on a 713 playlist nothing else. We have another method for the 714 song in playlist play pause method. 715 */ 716 if (song == null) { 717 /* 718 Determines what classes we should add and remove 719 from the elements. 720 */ 721 switch (state) { 722 case "playing": 723 setElementPlay(playlistPlayPauseElements[i]); 724 break; 725 case "paused": 726 setElementPause(playlistPlayPauseElements[i]); 727 break; 728 } 729 } 730 } 731 } 732 733 /** 734 * Syncs the song play pause buttons to the state of the active song. 735 * 736 * @access public 737 */ 738 function syncSong() { 739 var state = _config2.default.audio.paused ? "paused" : "playing"; 740 741 /* 742 Get all of the individual song play pause buttons. These have an 743 amplitude-song-index that matches the active index attribute. 744 */ 745 var songPlayPauseElements = document.querySelectorAll('.amplitude-play-pause[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 746 747 /* 748 Iterate over all of the song play pause elements 749 */ 750 for (var i = 0; i < songPlayPauseElements.length; i++) { 751 /* 752 Grab the playlist attributes from the element. 753 */ 754 var playlist = songPlayPauseElements[i].getAttribute("data-amplitude-playlist"); 755 756 /* 757 We want only the song play pause buttons, not ones scoped in a playlist. 758 */ 759 if (playlist == null) { 760 /* 761 Determines what classes we should add and remove 762 from the elements. 763 */ 764 switch (state) { 765 case "playing": 766 setElementPlay(songPlayPauseElements[i]); 767 break; 768 case "paused": 769 setElementPause(songPlayPauseElements[i]); 770 break; 771 } 772 } 773 } 774 } 775 776 /** 777 * Syncs the song in playlist play pause buttons to the state of 778 * the active song. 779 * 780 * @access public 781 */ 782 function syncSongInPlaylist() { 783 var state = _config2.default.audio.paused ? "paused" : "playing"; 784 785 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 786 787 /* 788 Get all of the individual song play pause buttons. These have an 789 amplitude-song-index attribute. Some have amplitude-playlist which 790 means they are individual songs within a playlist. 791 */ 792 var songInPlaylistPlayPauseElements = document.querySelectorAll('.amplitude-play-pause[data-amplitude-song-index="' + activePlaylistIndex + '"][data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 793 794 /* 795 Iterate over all of the individual play pause elements for songs inspect 796 a playlist. 797 */ 798 for (var i = 0; i < songInPlaylistPlayPauseElements.length; i++) { 799 /* 800 Determines what classes we should add and remove 801 from the elements. 802 */ 803 switch (state) { 804 case "playing": 805 setElementPlay(songInPlaylistPlayPauseElements[i]); 806 break; 807 case "paused": 808 setElementPause(songInPlaylistPlayPauseElements[i]); 809 break; 810 } 811 } 812 } 813 814 /** 815 * Sets all of the play pause buttons to paused. 816 * 817 * @access public 818 */ 819 function syncToPause() { 820 /* 821 Gets all of the play pause elements 822 */ 823 var playPauseElements = document.querySelectorAll(".amplitude-play-pause"); 824 825 /* 826 Sets all of the elements to pause 827 */ 828 for (var i = 0; i < playPauseElements.length; i++) { 829 setElementPause(playPauseElements[i]); 830 } 831 } 832 833 /** 834 * Sets an element to be playing by removing the 'amplitude-paused' class 835 * and adding the 'amplitude-playing' class 836 * 837 * @access public 838 * @param {element} element - The element getting the playing class added. 839 */ 840 function setElementPlay(element) { 841 element.classList.add("amplitude-playing"); 842 element.classList.remove("amplitude-paused"); 843 } 844 845 /** 846 * Sets an element to be paused by adding the 'amplitude-paused' class 847 * and removing the 'amplitude-playing' class 848 * 849 * @access public 850 * @param {element} element - The element getting the paused class added. 851 */ 852 function setElementPause(element) { 853 element.classList.remove("amplitude-playing"); 854 element.classList.add("amplitude-paused"); 855 } 856 857 /** 858 * Returns the public facing methods 859 */ 860 return { 861 sync: sync, 862 syncGlobal: syncGlobal, 863 syncPlaylist: syncPlaylist, 864 syncSong: syncSong, 865 syncSongInPlaylist: syncSongInPlaylist, 866 syncToPause: syncToPause 867 }; 868}(); /** 869 * Imports the config module 870 * @module config 871 */ 872exports.default = PlayPauseElements; 873module.exports = exports["default"]; 874 875/***/ }), 876/* 3 */ 877/***/ (function(module, exports, __webpack_require__) { 878 879"use strict"; 880 881 882Object.defineProperty(exports, "__esModule", { 883 value: true 884}); 885 886var _config = __webpack_require__(0); 887 888var _config2 = _interopRequireDefault(_config); 889 890var _core = __webpack_require__(1); 891 892var _core2 = _interopRequireDefault(_core); 893 894var _callbacks = __webpack_require__(9); 895 896var _callbacks2 = _interopRequireDefault(_callbacks); 897 898var _checks = __webpack_require__(5); 899 900var _checks2 = _interopRequireDefault(_checks); 901 902var _playPauseElements = __webpack_require__(2); 903 904var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 905 906var _songSliderElements = __webpack_require__(14); 907 908var _songSliderElements2 = _interopRequireDefault(_songSliderElements); 909 910var _songPlayedProgressElements = __webpack_require__(20); 911 912var _songPlayedProgressElements2 = _interopRequireDefault(_songPlayedProgressElements); 913 914var _timeElements = __webpack_require__(15); 915 916var _timeElements2 = _interopRequireDefault(_timeElements); 917 918var _metaDataElements = __webpack_require__(7); 919 920var _metaDataElements2 = _interopRequireDefault(_metaDataElements); 921 922var _containerElements = __webpack_require__(49); 923 924var _containerElements2 = _interopRequireDefault(_containerElements); 925 926function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 927 928/** 929 * AmplitudeJS Audio Navigation Utility. 930 * 931 * @module utilities/AudioNavigation 932 */ 933 934 935/** 936 * Meta Data Elements Module 937 * 938 * @module visual/MetaDataElements 939 */ 940 941 942/** 943 * Imports the Song Played Progress Elements Module 944 * 945 * @module visual/SongPlayedProgressElements 946 */ 947 948 949/** 950 * Imports the Play Pause Elements Module 951 * 952 * @module visual/PlayPauseElements 953 */ 954 955 956/** 957 * Imports the Callbacks Module 958 * 959 * @module utilities/Callbacks 960 */ 961/** 962 * Imports the config module 963 * @module config 964 */ 965var AudioNavigation = function () { 966 /** 967 * Sets the next song 968 * 969 * @access public 970 * @param {boolean} [songEnded=false] If the song ended, this is set to true 971 * so we take into effect the repeat setting. 972 */ 973 function setNext() { 974 var songEnded = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 975 976 /* 977 Initializes the next index variable. This will be the 978 index of the song that is next. 979 */ 980 var nextIndex = null; 981 var nextSong = {}; 982 983 /* 984 Ensure we don't loop in the playlist if config.repeat is not true 985 */ 986 var endOfList = false; 987 988 /* 989 Determines if we are repeating the song or not. If we are repeating, 990 the next song will be the same song index. 991 */ 992 if (_config2.default.repeat_song) { 993 /* 994 If the playlist is shuffled, get the now playing index. 995 */ 996 if (_config2.default.shuffle_on) { 997 nextIndex = _config2.default.shuffle_list[_config2.default.active_index].index; 998 nextSong = _config2.default.shuffle_list[nextIndex]; 999 } else { 1000 nextIndex = _config2.default.active_index; 1001 nextSong = _config2.default.songs[nextIndex]; 1002 } 1003 } else { 1004 /* 1005 If the shuffle is on, we use the shuffled list of 1006 songs to determine our next song. 1007 */ 1008 if (_config2.default.shuffle_on) { 1009 /* 1010 If the active shuffle index + 1 is less than the length, then 1011 we use the next shuffle otherwise we go to the beginning 1012 of the shuffle list. 1013 */ 1014 if (parseInt(_config2.default.active_index) + 1 < _config2.default.shuffle_list.length) { 1015 /* 1016 Set the next index to be the index of the song in the shuffle list. 1017 */ 1018 nextIndex = parseInt(_config2.default.active_index) + 1; 1019 } else { 1020 nextIndex = 0; 1021 endOfList = true; 1022 } 1023 1024 nextSong = _config2.default.shuffle_list[nextIndex]; 1025 } else { 1026 /* 1027 If the active index + 1 is less than the length of the songs, then 1028 we use the next song otherwise we go to the beginning of the 1029 song list. 1030 */ 1031 if (parseInt(_config2.default.active_index) + 1 < _config2.default.songs.length) { 1032 nextIndex = parseInt(_config2.default.active_index) + 1; 1033 } else { 1034 nextIndex = 0; 1035 endOfList = true; 1036 } 1037 1038 /* 1039 Sets the next index. 1040 */ 1041 nextSong = _config2.default.songs[nextIndex]; 1042 } 1043 } 1044 1045 /* 1046 Change the song after the next button has been pressed. 1047 */ 1048 changeSong(nextSong, nextIndex); 1049 1050 /* 1051 If it's the end of the list and repeat is not on, do nothing. 1052 */ 1053 if (endOfList && !_config2.default.repeat) {} else { 1054 /* 1055 If the song has ended and repeat is on, play the song. 1056 */ 1057 if (!(songEnded && !_config2.default.repeat && endOfList)) { 1058 _core2.default.play(); 1059 } 1060 } 1061 1062 /* 1063 Sync the play pause elements and run the 1064 after next callback. 1065 */ 1066 _playPauseElements2.default.sync(); 1067 _callbacks2.default.run("next"); 1068 1069 /* 1070 If we repeated the song, run the repeat song callback. 1071 */ 1072 if (_config2.default.repeat_song) { 1073 _callbacks2.default.run("song_repeated"); 1074 } 1075 } 1076 1077 /** 1078 * Sets the next song in a playlist 1079 * 1080 * @param {string} playlist - The playlist being shuffled 1081 * @param {boolean} [songEnded=false] - If the song ended, this is set to true 1082 * so we take into effect the repeat setting. 1083 */ 1084 function setNextPlaylist(playlist) { 1085 var songEnded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 1086 1087 /* 1088 Initializes the next index 1089 */ 1090 var nextIndex = null; 1091 var nextSong = {}; 1092 1093 /* 1094 Ensure we don't loop in the playlist if config.repeat is not true 1095 */ 1096 var endOfList = false; 1097 1098 /* 1099 If we are repeating the song, then we just start the song over. 1100 */ 1101 if (_config2.default.repeat_song) { 1102 /* 1103 If the playlist is shuffled, get the now playing index. 1104 */ 1105 if (_config2.default.playlists[playlist].shuffle) { 1106 nextIndex = _config2.default.playlists[playlist].active_index; 1107 nextSong = _config2.default.playlists[playlist].shuffle_list[nextIndex]; 1108 } else { 1109 nextIndex = _config2.default.playlists[playlist].active_index; 1110 nextSong = _config2.default.playlists[playlist].songs[nextIndex]; 1111 } 1112 } else { 1113 /* 1114 If the playlist is shuffled we get the next index of the playlist. 1115 */ 1116 if (_config2.default.playlists[playlist].shuffle) { 1117 /* 1118 If the active shuffle index + 1 is less than the length of the shuffle list, 1119 then we use the next shuffle otherwise we go to the beginning of the shuffle list. 1120 */ 1121 if (parseInt(_config2.default.playlists[playlist].active_index) + 1 < _config2.default.playlists[playlist].shuffle_list.length) { 1122 /* 1123 Set the next index to be the index of the song in the shuffle list. 1124 */ 1125 nextIndex = _config2.default.playlists[playlist].active_index + 1; 1126 } else { 1127 nextIndex = 0; 1128 endOfList = true; 1129 } 1130 1131 nextSong = _config2.default.playlists[playlist].shuffle_list[nextIndex]; 1132 } else { 1133 /* 1134 If the active index +1 is less than the length of the songs in the playlist, 1135 then we use the next song otherwise we go to the beginning of the playlist. 1136 */ 1137 if (parseInt(_config2.default.playlists[playlist].active_index) + 1 < _config2.default.playlists[playlist].songs.length) { 1138 nextIndex = parseInt(_config2.default.playlists[playlist].active_index) + 1; 1139 } else { 1140 nextIndex = 0; 1141 endOfList = true; 1142 } 1143 1144 /* 1145 Sets the next song. 1146 */ 1147 nextSong = _config2.default.playlists[playlist].songs[nextIndex]; 1148 } 1149 } 1150 1151 /* 1152 Sets the active playlist to the playlist we are on. 1153 */ 1154 setActivePlaylist(playlist); 1155 1156 /* 1157 Change the song within the playlist. 1158 */ 1159 changeSongPlaylist(playlist, nextSong, nextIndex); 1160 1161 /* 1162 If it's the end of the playlist and we aren't repeating, do nothing. 1163 */ 1164 if (endOfList && !_config2.default.repeat) {} else { 1165 if (!(songEnded && !_config2.default.repeat && endOfList)) { 1166 _core2.default.play(); 1167 } 1168 } 1169 1170 /* 1171 Sync the play pause buttons. 1172 */ 1173 _playPauseElements2.default.sync(); 1174 _callbacks2.default.run("next"); 1175 1176 /* 1177 Repeat the song. 1178 */ 1179 if (_config2.default.repeat_song) { 1180 _callbacks2.default.run("song_repeated"); 1181 } 1182 } 1183 1184 /** 1185 * Sets the previous song on the global songs array. 1186 * 1187 * @access private 1188 */ 1189 function setPrevious() { 1190 /* 1191 Initializes the previous index 1192 */ 1193 var previousIndex = null; 1194 var previousSong = {}; 1195 1196 /* 1197 If we are repeating the song, then we just start the song over. 1198 */ 1199 if (_config2.default.repeat_song) { 1200 /* 1201 If the config is shuffled, get the now playing index. 1202 */ 1203 if (_config2.default.shuffle_on) { 1204 previousIndex = _config2.default.active_index; 1205 previousSong = _config2.default.shuffle_list[previousIndex]; 1206 } else { 1207 previousIndex = _config2.default.active_index; 1208 previousSong = _config2.default.songs[previousIndex]; 1209 } 1210 } else { 1211 /* 1212 Get the previous index. If the previous index will be less than 0, get the 1213 last song of the array and continue. 1214 */ 1215 if (parseInt(_config2.default.active_index) - 1 >= 0) { 1216 previousIndex = parseInt(_config2.default.active_index - 1); 1217 } else { 1218 previousIndex = parseInt(_config2.default.songs.length - 1); 1219 } 1220 1221 /* 1222 If the config is shuffled, we grab the song from the shuffle list 1223 */ 1224 if (_config2.default.shuffle_on) { 1225 /* 1226 Grab song from the shuffle list 1227 */ 1228 previousSong = _config2.default.shuffle_list[previousIndex]; 1229 } else { 1230 /* 1231 Grab song from the songs array 1232 */ 1233 previousSong = _config2.default.songs[previousIndex]; 1234 } 1235 } 1236 /* 1237 Change the song after the next button has been pressed. 1238 */ 1239 changeSong(previousSong, previousIndex); 1240 1241 /* 1242 Play the newest song. 1243 */ 1244 _core2.default.play(); 1245 1246 /* 1247 Sync the play pause elements and run the 1248 after next callback. 1249 */ 1250 _playPauseElements2.default.sync(); 1251 _callbacks2.default.run("prev"); 1252 1253 /* 1254 If we repeated the song, run the repeat song callback. 1255 */ 1256 if (_config2.default.repeat_song) { 1257 _callbacks2.default.run("song_repeated"); 1258 } 1259 } 1260 1261 /** 1262 * Sets the previous playlist song. 1263 * 1264 * @access private 1265 * 1266 * @prop {string} playlist - The playlist we are navigating in. 1267 */ 1268 function setPreviousPlaylist(playlist) { 1269 /* 1270 Initializes the previous index 1271 */ 1272 var previousIndex = null; 1273 var previousSong = {}; 1274 1275 /* 1276 If we are repeating the song, then we just start the song over. 1277 */ 1278 if (_config2.default.repeat_song) { 1279 /* 1280 If the playlist is shuffled, get the now playing index. 1281 */ 1282 if (_config2.default.playlists[playlist].shuffle) { 1283 previousIndex = _config2.default.playlists[playlist].active_index; 1284 previousSong = _config2.default.playlists[playlist].shuffle_list[previousIndex]; 1285 } else { 1286 previousIndex = _config2.default.playlists[playlist].active_index; 1287 previousSong = _config2.default.playlists[playlist].songs[previousIndex]; 1288 } 1289 } else { 1290 /* 1291 Get the previous index. If the previous index will be less than 0, get the 1292 last song of the array and continue. 1293 */ 1294 if (parseInt(_config2.default.playlists[playlist].active_index) - 1 >= 0) { 1295 previousIndex = parseInt(_config2.default.playlists[playlist].active_index - 1); 1296 } else { 1297 previousIndex = parseInt(_config2.default.playlists[playlist].songs.length - 1); 1298 } 1299 1300 /* 1301 If the playlist is shuffled, we grab the song from the shuffle list 1302 */ 1303 if (_config2.default.playlists[playlist].shuffle) { 1304 /* 1305 Grab song from the shuffle list 1306 */ 1307 previousSong = _config2.default.playlists[playlist].shuffle_list[previousIndex]; 1308 } else { 1309 /* 1310 Grab song from the songs array 1311 */ 1312 previousSong = _config2.default.playlists[playlist].songs[previousIndex]; 1313 } 1314 } 1315 1316 /* 1317 Sets the active playlist to the playlist we are on. 1318 */ 1319 setActivePlaylist(playlist); 1320 1321 /* 1322 Change the song within the playlist. 1323 */ 1324 changeSongPlaylist(playlist, previousSong, previousIndex); 1325 1326 /* 1327 Plays the song 1328 */ 1329 _core2.default.play(); 1330 1331 /* 1332 Sync the play pause buttons. 1333 */ 1334 _playPauseElements2.default.sync(); 1335 _callbacks2.default.run("prev"); 1336 1337 /* 1338 Repeat the song. 1339 */ 1340 if (_config2.default.repeat_song) { 1341 _callbacks2.default.run("song_repeated"); 1342 } 1343 } 1344 1345 /** 1346 * Change song in the songs array. 1347 * 1348 * @access private 1349 * @prop {object} song - The song we are changing to. 1350 * @prop {number} index - The index we are changing to. 1351 * @prop {boolean} direct - Determines if it was a direct click on the song. 1352 * We then don't care if shuffle is on or not. 1353 */ 1354 function changeSong(song, index) { 1355 var direct = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 1356 1357 /* 1358 Prepare the song change. 1359 */ 1360 prepareSongChange(song); 1361 1362 /* 1363 Change the song. 1364 */ 1365 _config2.default.audio.src = song.url; 1366 _config2.default.active_metadata = song; 1367 _config2.default.active_album = song.album; 1368 1369 _config2.default.active_index = parseInt(index); 1370 1371 /* 1372 Set new information now that the song has changed. 1373 */ 1374 afterSongChange(direct); 1375 } 1376 1377 /** 1378 * Handles a song change in the playlist 1379 * 1380 * @access private 1381 * @prop {string} playlist - The playlist we are changing the song on. 1382 * @prop {object} song - The song we are changing to in the playlist. 1383 * @prop {number} index - The inded of the song we are changing to in the playlist. 1384 * @prop {boolean} direct - Determines if it was a direct click on the song. We 1385 * then don't care if shuffle is on or not 1386 */ 1387 function changeSongPlaylist(playlist, song, index) { 1388 var direct = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 1389 1390 /* 1391 Prepare the song change. 1392 */ 1393 prepareSongChange(song); 1394 1395 /* 1396 Change the song. 1397 */ 1398 _config2.default.audio.src = song.url; 1399 _config2.default.active_metadata = song; 1400 _config2.default.active_album = song.album; 1401 _config2.default.active_index = null; 1402 1403 _config2.default.playlists[playlist].active_index = parseInt(index); 1404 1405 /* 1406 Set new information now that the song has changed. 1407 */ 1408 afterSongChange(direct); 1409 } 1410 1411 /** 1412 * Prepares a song change 1413 * 1414 * @access private 1415 * @prop {object} song - The song we change to. 1416 */ 1417 function prepareSongChange(song) { 1418 /* 1419 Stop the current song. 1420 */ 1421 _core2.default.stop(); 1422 1423 /* 1424 Sync all of the elements to a stopped song. 1425 */ 1426 _playPauseElements2.default.syncToPause(); 1427 _songSliderElements2.default.resetElements(); 1428 _songPlayedProgressElements2.default.resetElements(); 1429 _timeElements2.default.resetCurrentTimes(); 1430 1431 /* 1432 If an album changes, fire an album change. 1433 */ 1434 if (_checks2.default.newAlbum(song)) { 1435 _callbacks2.default.run("album_change"); 1436 } 1437 } 1438 1439 /** 1440 * Updates data on the display after a song has changed. 1441 * 1442 * @prop {boolean} direct - Determines if it was a direct click on the song. 1443 * We then don't care if shuffle is on or not. 1444 * 1445 * @access private 1446 */ 1447 function afterSongChange(direct) { 1448 _metaDataElements2.default.displayMetaData(); 1449 _containerElements2.default.setActive(direct); 1450 _timeElements2.default.resetDurationTimes(); 1451 1452 /* 1453 Run the song change callback. 1454 */ 1455 _callbacks2.default.run("song_change"); 1456 } 1457 1458 /** 1459 * Sets the active playlist 1460 * 1461 * @access public 1462 * @param {string} playlist - The string of the playlist being set to active. 1463 */ 1464 function setActivePlaylist(playlist) { 1465 /* 1466 If the active playlist is different than the playlist being set, 1467 we run the `playlist_changed` callback. 1468 */ 1469 if (_config2.default.active_playlist != playlist) { 1470 _callbacks2.default.run("playlist_changed"); 1471 /* 1472 Set the active playlist to the playlist parameter. Only need to 1473 set if it's different. 1474 */ 1475 _config2.default.active_playlist = playlist; 1476 1477 if (playlist != null) { 1478 _config2.default.playlists[playlist].active_index = 0; 1479 } 1480 } 1481 } 1482 1483 /* 1484 Return the publically facing methods 1485 */ 1486 return { 1487 setNext: setNext, 1488 setNextPlaylist: setNextPlaylist, 1489 setPrevious: setPrevious, 1490 setPreviousPlaylist: setPreviousPlaylist, 1491 changeSong: changeSong, 1492 changeSongPlaylist: changeSongPlaylist, 1493 setActivePlaylist: setActivePlaylist 1494 }; 1495}(); 1496 1497/** 1498 * Container Elements Module 1499 * 1500 * @module visual/ContainerElements 1501 */ 1502 1503 1504/** 1505 * Imports the Time Elements Module 1506 * 1507 * @module visual/TimeElements 1508 */ 1509 1510 1511/** 1512 * Imports the Song Slider Elements Module 1513 * 1514 * @module visual/SongSliderElements 1515 */ 1516 1517 1518/** 1519 * Imports the Checks Module 1520 * 1521 * @module utilities/Checks 1522 */ 1523 1524 1525/** 1526 * Imports the Core Module 1527 * 1528 * @module core/Core 1529 */ 1530exports.default = AudioNavigation; 1531module.exports = exports["default"]; 1532 1533/***/ }), 1534/* 4 */ 1535/***/ (function(module, exports, __webpack_require__) { 1536 1537"use strict"; 1538 1539 1540Object.defineProperty(exports, "__esModule", { 1541 value: true 1542}); 1543 1544var _config = __webpack_require__(0); 1545 1546var _config2 = _interopRequireDefault(_config); 1547 1548function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1549 1550/** 1551 * Handles the debugging of AmplitudeJS 1552 * @module utilities/Debug 1553 */ 1554var Debug = function () { 1555 /** 1556 * Writes out debug message to the console if enabled. 1557 * 1558 * Public Accessor: Debug.writeMessage( message ) 1559 * 1560 * @access public 1561 * @param {string} message - The string that gets printed to alert the user of a debugging error. 1562 */ 1563 function writeMessage(message) { 1564 /* 1565 If the user has flagged AmplitudeJS to debug, we print out a message 1566 to the console. 1567 */ 1568 if (_config2.default.debug) { 1569 console.log(message); 1570 } 1571 } 1572 1573 /* 1574 Returns the public facing methods 1575 */ 1576 return { 1577 writeMessage: writeMessage 1578 }; 1579}(); /** 1580 * Imports the config module 1581 * @module config 1582 */ 1583exports.default = Debug; 1584module.exports = exports["default"]; 1585 1586/***/ }), 1587/* 5 */ 1588/***/ (function(module, exports, __webpack_require__) { 1589 1590"use strict"; 1591 1592 1593Object.defineProperty(exports, "__esModule", { 1594 value: true 1595}); 1596 1597var _config = __webpack_require__(0); 1598 1599var _config2 = _interopRequireDefault(_config); 1600 1601function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1602 1603/** 1604 * AmplitudeJS Checks Module. Checks for new songs, albums, and playlists 1605 * 1606 * @module utilities/Checks 1607 */ 1608var Checks = function () { 1609 /** 1610 * Checks to see if the new song to be played is different than the song 1611 * that is currently playing. To be true, the user would have selected 1612 * play on a new song with a new index. To be false, the user would have 1613 * clicked play/pause on the song that was playing. 1614 * 1615 * Public Accessor: Checks.newSong( playlist, songIndex ) 1616 * @access public 1617 * @param {string} playlist - The playlist we are checking the new song for. Could be null 1618 * @param {number} songIndex - The index of the new song to be played. 1619 * @returns {boolean} True if we are setting a new song, false if we are not setting a new song. 1620 */ 1621 function newSong(playlist, songIndex) { 1622 /* 1623 If the playlists don't match, then it's definitely a new song. 1624 */ 1625 if (_config2.default.active_playlist != playlist) { 1626 return true; 1627 } else { 1628 /* 1629 If we aren't in a playlist, we check the active index. 1630 */ 1631 if (_config2.default.active_playlist == null && playlist == null) { 1632 /* 1633 If the active indexes don't match, then it's a new song. 1634 */ 1635 if (_config2.default.active_index != songIndex) { 1636 return true; 1637 } else { 1638 return false; 1639 } 1640 } else { 1641 /* 1642 If we are in a playlist, then we check to see if the 1643 new song index matches the active index. 1644 */ 1645 if (_config2.default.active_playlist == playlist && _config2.default.playlists[playlist].active_index != songIndex) { 1646 return true; 1647 } else { 1648 return false; 1649 } 1650 } 1651 } 1652 } 1653 1654 /** 1655 * Checks to see if there is a new album 1656 * 1657 * Public Accessor: Checks.newAlbum( album ) 1658 * 1659 * @access public 1660 * @param {string} album - Checks to see if the new song will have a new album. 1661 * @returns {boolean} True if there is a new album, false if there is not a new ablum. 1662 */ 1663 function newAlbum(album) { 1664 if (_config2.default.active_album != album) { 1665 return true; 1666 } else { 1667 return false; 1668 } 1669 } 1670 1671 /** 1672 * Checks to see if there is a new playlist 1673 * 1674 * Public Accessor: Checks.newPlaylist( playlist ) 1675 * 1676 * @access public 1677 * @param {string} playlist - The playlist passed in to check against the active playlist. 1678 * @returns {boolean} True if there is a new playlist, false if there is not a new playlist. 1679 */ 1680 function newPlaylist(playlist) { 1681 if (_config2.default.active_playlist != playlist) { 1682 return true; 1683 } else { 1684 return false; 1685 } 1686 } 1687 1688 /** 1689 * Determines if the string passed in is a URL or not 1690 * 1691 * Public Accessor: AmplitudeHelpers.isURL( url ) 1692 * 1693 * @access public 1694 * @param {string} url - The string we are testing to see if it's a URL. 1695 * @returns {boolean} True if the string is a url, false if it is not. 1696 */ 1697 function isURL(url) { 1698 /* 1699 Test the string against the URL pattern and return if it matches 1700 */ 1701 var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; 1702 1703 return pattern.test(url); 1704 } 1705 1706 /** 1707 * Determines if what is passed in is an integer or not. 1708 * 1709 * Public Accessor: AmplitudeHelpers.isInt( int ) 1710 * 1711 * @access public 1712 * @param {string|number} int - The variable we are testing to see is an integer or not. 1713 * @returns {boolean} If the variable is an integer or not. 1714 */ 1715 function isInt(int) { 1716 return !isNaN(int) && parseInt(Number(int)) == int && !isNaN(parseInt(int, 10)); 1717 } 1718 1719 /** 1720 * Returns public facing methods 1721 */ 1722 return { 1723 newSong: newSong, 1724 newAlbum: newAlbum, 1725 newPlaylist: newPlaylist, 1726 isURL: isURL, 1727 isInt: isInt 1728 }; 1729}(); /** 1730 * Imports the config module 1731 * @module config 1732 */ 1733exports.default = Checks; 1734module.exports = exports["default"]; 1735 1736/***/ }), 1737/* 6 */ 1738/***/ (function(module, exports, __webpack_require__) { 1739 1740"use strict"; 1741 1742 1743Object.defineProperty(exports, "__esModule", { 1744 value: true 1745}); 1746 1747var _config = __webpack_require__(0); 1748 1749var _config2 = _interopRequireDefault(_config); 1750 1751function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1752 1753/** 1754 * Handles the state of the config object. 1755 * 1756 * @module utilities/ConfigState 1757 */ 1758var ConfigState = function () { 1759 /** 1760 * Resets the config to the default state. This is called on initialize 1761 * to ensure the user's config is what matters. 1762 * 1763 * Public Accessor: AmplitudeHelpers.resetConfig() 1764 * 1765 * @access public 1766 */ 1767 function resetConfig() { 1768 _config2.default.audio = new Audio(); 1769 _config2.default.active_metadata = {}; 1770 _config2.default.active_album = ""; 1771 _config2.default.active_index = 0; 1772 _config2.default.active_playlist = null; 1773 _config2.default.playback_speed = 1.0; 1774 _config2.default.callbacks = {}; 1775 _config2.default.songs = []; 1776 _config2.default.playlists = {}; 1777 _config2.default.start_song = ""; 1778 _config2.default.starting_playlist = ""; 1779 _config2.default.starting_playlist_song = ""; 1780 _config2.default.repeat = false; 1781 _config2.default.shuffle_list = {}; 1782 _config2.default.shuffle_on = false; 1783 _config2.default.default_album_art = ""; 1784 _config2.default.default_playlist_art = ""; 1785 _config2.default.debug = false; 1786 _config2.default.volume = 0.5; 1787 _config2.default.pre_mute_volume = 0.5; 1788 _config2.default.volume_increment = 5; 1789 _config2.default.volume_decrement = 5; 1790 _config2.default.soundcloud_client = ""; 1791 _config2.default.soundcloud_use_art = false; 1792 _config2.default.soundcloud_song_count = 0; 1793 _config2.default.soundcloud_songs_ready = 0; 1794 _config2.default.continue_next = true; 1795 } 1796 1797 /** 1798 * Sets the state of the player. 1799 */ 1800 function setPlayerState() { 1801 /* 1802 If paused and the current time is 0 the player is stopped. 1803 */ 1804 if (_config2.default.audio.paused && _config2.default.audio.currentTime == 0) { 1805 _config2.default.player_state = "stopped"; 1806 } 1807 1808 /* 1809 If paused and the current time is greater than 0 the player is 1810 paused. 1811 */ 1812 if (_config2.default.audio.paused && _config2.default.audio.currentTime > 0) { 1813 _config2.default.player_state = "paused"; 1814 } 1815 1816 /* 1817 If playing, the current state is playing. 1818 */ 1819 if (!_config2.default.audio.paused) { 1820 _config2.default.player_state = "playing"; 1821 } 1822 } 1823 1824 /* 1825 Returns the public facing methods 1826 */ 1827 return { 1828 resetConfig: resetConfig, 1829 setPlayerState: setPlayerState 1830 }; 1831}(); /** 1832 * Imports the config module 1833 * @module config 1834 */ 1835exports.default = ConfigState; 1836module.exports = exports["default"]; 1837 1838/***/ }), 1839/* 7 */ 1840/***/ (function(module, exports, __webpack_require__) { 1841 1842"use strict"; 1843 1844 1845Object.defineProperty(exports, "__esModule", { 1846 value: true 1847}); 1848 1849var _config = __webpack_require__(0); 1850 1851var _config2 = _interopRequireDefault(_config); 1852 1853function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1854 1855/** 1856 * These methods help display the audio's meta data 1857 * 1858 * @module visual/MetaDataElements 1859 */ 1860var MetaDataElements = function () { 1861 /** 1862 * Displays the active song's metadata. This is called after a song has 1863 * been changed. This method takes the active song and displays the 1864 * metadata. So once the new active song is set, we update all of the 1865 * screen elements. 1866 * 1867 * @access public 1868 */ 1869 function displayMetaData() { 1870 /* 1871 Define the image meta data keys. These are managed separately 1872 since we aren't actually changing the inner HTML of these elements. 1873 */ 1874 var imageMetaDataKeys = ["cover_art_url", "station_art_url", "podcast_episode_cover_art_url"]; 1875 1876 /* 1877 Get all of the song info elements 1878 */ 1879 var songInfoElements = document.querySelectorAll("[data-amplitude-song-info]"); 1880 1881 /* 1882 Iterate over all of the song info elements. We will either 1883 set these to the new values, or clear them if the active song 1884 doesn't have the info set. 1885 */ 1886 for (var i = 0; i < songInfoElements.length; i++) { 1887 /* 1888 Get the info so we can check if the active meta data has the 1889 key. 1890 */ 1891 var info = songInfoElements[i].getAttribute("data-amplitude-song-info"); 1892 1893 /* 1894 Grab the playlist and song index. 1895 */ 1896 var playlist = songInfoElements[i].getAttribute("data-amplitude-playlist"); 1897 var songIndex = songInfoElements[i].getAttribute("data-amplitude-song-index"); 1898 1899 /* 1900 Ensure that we don't set any individual elements now. We set this with the 1901 sync meta data method. The reason we don't set them here is because 1902 all individual songs would get the now playing artwork. If the playlists 1903 match or the element is a main element meaning it doesn't 1904 belong to a playlist or a song, then we set the song info. 1905 */ 1906 if (songIndex == null && (_config2.default.active_playlist == playlist || playlist == null && songIndex == null)) { 1907 /* 1908 If the active metadata has the key, then we set it, 1909 otherwise we clear it. If it's an image element then 1910 we default it to the default info if needed. 1911 */ 1912 var val = _config2.default.active_metadata[info] != undefined ? _config2.default.active_metadata[info] : null; 1913 if (imageMetaDataKeys.indexOf(info) >= 0) { 1914 val = val || _config2.default.default_album_art; 1915 songInfoElements[i].setAttribute("src", val); 1916 } else { 1917 val = val || ""; 1918 songInfoElements[i].innerHTML = val; 1919 } 1920 } 1921 } 1922 } 1923 1924 /** 1925 * Displays the playlist meta data. 1926 */ 1927 function displayPlaylistMetaData() { 1928 /* 1929 Define the image meta data keys. These are managed separately 1930 since we aren't actually changing the inner HTML of these elements. 1931 */ 1932 var imageMetaDataKeys = ["image_url"]; 1933 1934 /* 1935 Get all of the playlist info elements 1936 */ 1937 var playlistInfoElements = document.querySelectorAll("[data-amplitude-playlist-info]"); 1938 1939 /* 1940 Iterate over all of the playlist info elements. We will either 1941 set these to the new values, or clear them if the active song 1942 doesn't have the info set. 1943 */ 1944 for (var i = 0; i < playlistInfoElements.length; i++) { 1945 /* 1946 Get the info so we can check if the active meta data has the 1947 key. 1948 */ 1949 var info = playlistInfoElements[i].getAttribute("data-amplitude-playlist-info"); 1950 var playlist = playlistInfoElements[i].getAttribute("data-amplitude-playlist"); 1951 1952 if (_config2.default.playlists[playlist][info] != undefined) { 1953 if (imageMetaDataKeys.indexOf(info) >= 0) { 1954 playlistInfoElements[i].setAttribute("src", _config2.default.playlists[playlist][info]); 1955 } else { 1956 playlistInfoElements[i].innerHTML = _config2.default.playlists[playlist][info]; 1957 } 1958 } else { 1959 /* 1960 We look for the default album art because 1961 the actual key didn't exist. If the default album 1962 art doesn't exist then we set the src attribute 1963 to null. 1964 */ 1965 if (imageMetaDataKeys.indexOf(info) >= 0) { 1966 if (_config2.default.default_playlist_art != "") { 1967 playlistInfoElements[i].setAttribute("src", _config2.default.default_playlist_art); 1968 } else { 1969 playlistInfoElements[i].setAttribute("src", ""); 1970 } 1971 } else { 1972 playlistInfoElements[i].innerHTML = ""; 1973 } 1974 } 1975 } 1976 } 1977 1978 /** 1979 * Sets the first song in the playlist. This is used to fill in the meta 1980 * data in the playlist 1981 * 1982 * @param {object} song - The song we are setting to be the first song in the playlist 1983 * @param {string} playlist - Key of the playlist we are setting the first song in 1984 */ 1985 function setFirstSongInPlaylist(song, playlist) { 1986 /* 1987 Define the image meta data keys. These are managed separately 1988 since we aren't actually changing the inner HTML of these elements. 1989 */ 1990 var imageMetaDataKeys = ["cover_art_url", "station_art_url", "podcast_episode_cover_art_url"]; 1991 1992 /* 1993 Get all of the song info elements 1994 */ 1995 var songInfoElements = document.querySelectorAll('[data-amplitude-song-info][data-amplitude-playlist="' + playlist + '"]'); 1996 1997 /* 1998 Iterate over all of the song info elements. We will either 1999 set these to the new values, or clear them if the active song 2000 doesn't have the info set. 2001 */ 2002 for (var i = 0; i < songInfoElements.length; i++) { 2003 /* 2004 Get the info so we can check if the active meta data has the 2005 key. 2006 */ 2007 var info = songInfoElements[i].getAttribute("data-amplitude-song-info"); 2008 2009 /* 2010 Get the song info element playlist. 2011 */ 2012 var elementPlaylist = songInfoElements[i].getAttribute("data-amplitude-playlist"); 2013 2014 /* 2015 If the playlists match or the element is a main element, then 2016 we set the song info. 2017 */ 2018 if (elementPlaylist == playlist) { 2019 /* 2020 If the active metadata has the key, then we set it, 2021 otherwise we clear it. If it's an image element then 2022 we default it to the default info if needed. 2023 */ 2024 if (song[info] != undefined) { 2025 if (imageMetaDataKeys.indexOf(info) >= 0) { 2026 songInfoElements[i].setAttribute("src", song[info]); 2027 } else { 2028 songInfoElements[i].innerHTML = song[info]; 2029 } 2030 } else { 2031 /* 2032 We look for the default album art because 2033 the actual key didn't exist. If the default album 2034 art doesn't exist then we set the src attribute 2035 to null. 2036 */ 2037 if (imageMetaDataKeys.indexOf(info) >= 0) { 2038 if (song.default_album_art != "") { 2039 songInfoElements[i].setAttribute("src", song.default_album_art); 2040 } else { 2041 songInfoElements[i].setAttribute("src", ""); 2042 } 2043 } else { 2044 songInfoElements[i].innerHTML = ""; 2045 } 2046 } 2047 } 2048 } 2049 } 2050 2051 /** 2052 * Sets the meta data for songs loaded in the songs array 2053 */ 2054 function syncMetaData() { 2055 /* 2056 Define the image meta data keys. These are managed separately 2057 since we aren't actually changing the inner HTML of these elements. 2058 */ 2059 var imageMetaDataKeys = ["cover_art_url", "station_art_url", "podcast_episode_cover_art_url"]; 2060 2061 /* 2062 Get all of the song info elements 2063 */ 2064 var songInfoElements = document.querySelectorAll("[data-amplitude-song-info]"); 2065 2066 /* 2067 Iterate over all of the song info elements. We will either 2068 set these to the new values, or clear them if the active song 2069 doesn't have the info set. 2070 */ 2071 for (var i = 0; i < songInfoElements.length; i++) { 2072 var songIndex = songInfoElements[i].getAttribute("data-amplitude-song-index"); 2073 var playlist = songInfoElements[i].getAttribute("data-amplitude-playlist"); 2074 2075 if (songIndex != null && playlist == null) { 2076 var info = songInfoElements[i].getAttribute("data-amplitude-song-info"); 2077 2078 /* 2079 Get the song info value referenced on the element. Depending on the type of 2080 element, we may need to fallback to another value when the direct value 2081 we want isn't found. 2082 i.e. 2083 data-amplitude-song-info="cover_art_url" defaults to using the value 2084 of "default_album_art" when "cover_art_url" is missing on the song. 2085 */ 2086 var val = _config2.default.songs[songIndex][info] != undefined ? _config2.default.songs[songIndex][info] : null; 2087 /* 2088 If it's an image meta data key, then we set the src attribute of 2089 the element. Otherwise we set the inner HTML of the element. 2090 */ 2091 if (imageMetaDataKeys.indexOf(info) >= 0) { 2092 /* 2093 If this is an image meta data key and the individual song doesn't 2094 have the key, use the default_album_art 2095 */ 2096 val = val || _config2.default.default_album_art; 2097 songInfoElements[i].setAttribute("src", val); 2098 } else { 2099 songInfoElements[i].innerHTML = val; 2100 } 2101 } 2102 2103 /* 2104 If the song index and playlist are not null, continue. 2105 */ 2106 if (songIndex != null && playlist != null) { 2107 /* 2108 Get the info we are displaying. 2109 */ 2110 var _info = songInfoElements[i].getAttribute("data-amplitude-song-info"); 2111 2112 /* 2113 Set the meta data accordingly. 2114 */ 2115 if (_config2.default.playlists[playlist].songs[songIndex][_info] != undefined) { 2116 if (imageMetaDataKeys.indexOf(_info) >= 0) { 2117 songInfoElements[i].setAttribute("src", _config2.default.playlists[playlist].songs[songIndex][_info]); 2118 } else { 2119 songInfoElements[i].innerHTML = _config2.default.playlists[playlist].songs[songIndex][_info]; 2120 } 2121 } 2122 } 2123 } 2124 2125 /* 2126 Display the playlist meta data. 2127 */ 2128 displayPlaylistMetaData(); 2129 } 2130 2131 /** 2132 * Returns publically facing methods 2133 */ 2134 return { 2135 displayMetaData: displayMetaData, 2136 setFirstSongInPlaylist: setFirstSongInPlaylist, 2137 syncMetaData: syncMetaData, 2138 displayPlaylistMetaData: displayPlaylistMetaData 2139 }; 2140}(); /** 2141 * Imports the config module 2142 * @module config 2143 */ 2144exports.default = MetaDataElements; 2145module.exports = exports["default"]; 2146 2147/***/ }), 2148/* 8 */ 2149/***/ (function(module, exports, __webpack_require__) { 2150 2151"use strict"; 2152 2153 2154Object.defineProperty(exports, "__esModule", { 2155 value: true 2156}); 2157 2158var _config = __webpack_require__(0); 2159 2160var _config2 = _interopRequireDefault(_config); 2161 2162function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2163 2164/** 2165 * Handles all of the visual syncing to the state of the config for the repeat 2166 * elements. 2167 * 2168 * @module visual/RepeatElements 2169 */ 2170var RepeatElements = function () { 2171 /** 2172 * Syncs repeat for all of the repeat buttons. Users 2173 * can apply styles to the 'amplitude-repeat-on' and 2174 * 'amplitude-repeat-off' classes. They represent the state 2175 * of the player. 2176 */ 2177 function syncRepeat() { 2178 /* 2179 Gets all of the repeat classes 2180 */ 2181 var repeatClasses = document.getElementsByClassName("amplitude-repeat"); 2182 2183 /* 2184 Iterate over all of the repeat classes. If repeat is on, 2185 then add the 'amplitude-repeat-on' class and remove the 2186 'amplitude-repeat-off' class. If it's off, then do the 2187 opposite. 2188 */ 2189 for (var i = 0; i < repeatClasses.length; i++) { 2190 if (_config2.default.repeat) { 2191 repeatClasses[i].classList.add("amplitude-repeat-on"); 2192 repeatClasses[i].classList.remove("amplitude-repeat-off"); 2193 } else { 2194 repeatClasses[i].classList.remove("amplitude-repeat-on"); 2195 repeatClasses[i].classList.add("amplitude-repeat-off"); 2196 } 2197 } 2198 } 2199 2200 /** 2201 * Syncs repeat for all of the playlist repeat buttons. Users 2202 * can apply styles to the `amplitude-repeat-on` and `amplitude-repeat-off` 2203 * classes. They repreent the state of the playlist in the player. 2204 */ 2205 function syncRepeatPlaylist(playlist) { 2206 /* 2207 Gets all of the repeat buttons. 2208 */ 2209 var repeatButtons = document.getElementsByClassName("amplitude-repeat"); 2210 2211 /* 2212 Iterate over all of the repeat buttons 2213 */ 2214 for (var i = 0; i < repeatButtons.length; i++) { 2215 /* 2216 Ensure that the repeat button belongs to matches the 2217 playlist we are syncing the state for. 2218 */ 2219 if (repeatButtons[i].getAttribute("data-amplitude-playlist") == playlist) { 2220 /* 2221 If the state of the playlist is shuffled on, true, then 2222 we add the 'amplitude-repeat-on' class and remove the 2223 'amplitude-repeat-off' class. If the player is not shuffled 2224 then we do the opposite. 2225 */ 2226 if (_config2.default.playlists[playlist].repeat) { 2227 repeatButtons[i].classList.add("amplitude-repeat-on"); 2228 repeatButtons[i].classList.remove("amplitude-repeat-off"); 2229 } else { 2230 repeatButtons[i].classList.add("amplitude-repeat-off"); 2231 repeatButtons[i].classList.remove("amplitude-repeat-on"); 2232 } 2233 } 2234 } 2235 } 2236 2237 /** 2238 * Syncs repeat for all of the repeat song buttons. Users 2239 * can apply styles to the 'amplitude-repeat-song-on' and 2240 * 'amplitude-repeat-song-off' classes. They represent the state 2241 * of the player. 2242 */ 2243 function syncRepeatSong() { 2244 /* 2245 Gets all of the repeat song classes 2246 */ 2247 var repeatSongClasses = document.getElementsByClassName("amplitude-repeat-song"); 2248 2249 /* 2250 Iterate over all of the repeat song classes. If repeat is on, 2251 then add the 'amplitude-repeat-song-on' class and remove the 2252 'amplitude-repeat-song-off' class. If it's off, then do the 2253 opposite. 2254 */ 2255 for (var i = 0; i < repeatSongClasses.length; i++) { 2256 if (_config2.default.repeat_song) { 2257 repeatSongClasses[i].classList.add("amplitude-repeat-song-on"); 2258 repeatSongClasses[i].classList.remove("amplitude-repeat-song-off"); 2259 } else { 2260 repeatSongClasses[i].classList.remove("amplitude-repeat-song-on"); 2261 repeatSongClasses[i].classList.add("amplitude-repeat-song-off"); 2262 } 2263 } 2264 } 2265 2266 /* 2267 Returns the publically available methods. 2268 */ 2269 return { 2270 syncRepeat: syncRepeat, 2271 syncRepeatPlaylist: syncRepeatPlaylist, 2272 syncRepeatSong: syncRepeatSong 2273 }; 2274}(); /** 2275 * Imports the config module 2276 * @module config 2277 */ 2278exports.default = RepeatElements; 2279module.exports = exports["default"]; 2280 2281/***/ }), 2282/* 9 */ 2283/***/ (function(module, exports, __webpack_require__) { 2284 2285"use strict"; 2286 2287 2288Object.defineProperty(exports, "__esModule", { 2289 value: true 2290}); 2291 2292var _config = __webpack_require__(0); 2293 2294var _config2 = _interopRequireDefault(_config); 2295 2296var _debug = __webpack_require__(4); 2297 2298var _debug2 = _interopRequireDefault(_debug); 2299 2300function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2301 2302/** 2303 * AmplitudeJS Callback Utility 2304 * 2305 * @module utilities/callbacks 2306 */ 2307/** 2308 * Imports the config module 2309 * @module config 2310 */ 2311var Callbacks = function () { 2312 /** 2313 * Initializes the callbacks for the player. 2314 */ 2315 function initialize() { 2316 /* 2317 Event: abort 2318 https://www.w3schools.com/tags/av_event_abort.asp 2319 */ 2320 _config2.default.audio.addEventListener("abort", function () { 2321 run("abort"); 2322 }); 2323 2324 /* 2325 Event: error 2326 https://www.w3schools.com/tags/av_event_error.asp 2327 */ 2328 _config2.default.audio.addEventListener("error", function () { 2329 run("error"); 2330 }); 2331 2332 /* 2333 Event: loadeddata 2334 https://www.w3schools.com/tags/av_event_loadeddata.asp 2335 */ 2336 _config2.default.audio.addEventListener("loadeddata", function () { 2337 run("loadeddata"); 2338 }); 2339 2340 /* 2341 Event: loadedmetadata 2342 https://www.w3schools.com/tags/av_event_loadedmetadata.asp 2343 */ 2344 _config2.default.audio.addEventListener("loadedmetadata", function () { 2345 run("loadedmetadata"); 2346 }); 2347 2348 /* 2349 Event: loadstart 2350 https://www.w3schools.com/tags/av_event_loadstart.asp 2351 */ 2352 _config2.default.audio.addEventListener("loadstart", function () { 2353 run("loadstart"); 2354 }); 2355 2356 /* 2357 Event: pause 2358 https://www.w3schools.com/tags/av_event_pause.asp 2359 */ 2360 _config2.default.audio.addEventListener("pause", function () { 2361 run("pause"); 2362 }); 2363 2364 /* 2365 Event: playing 2366 https://www.w3schools.com/tags/av_event_playing.asp 2367 */ 2368 _config2.default.audio.addEventListener("playing", function () { 2369 run("playing"); 2370 }); 2371 2372 /* 2373 Event: play 2374 https://www.w3schools.com/tags/av_event_play.asp 2375 */ 2376 _config2.default.audio.addEventListener("play", function () { 2377 run("play"); 2378 }); 2379 2380 /* 2381 Event: progress 2382 https://www.w3schools.com/tags/av_event_progress.asp 2383 */ 2384 _config2.default.audio.addEventListener("progress", function () { 2385 run("progress"); 2386 }); 2387 2388 /* 2389 Event: ratechange 2390 https://www.w3schools.com/tags/av_event_ratechange.asp 2391 */ 2392 _config2.default.audio.addEventListener("ratechange", function () { 2393 run("ratechange"); 2394 }); 2395 2396 /* 2397 Event: seeked 2398 https://www.w3schools.com/tags/av_event_seeked.asp 2399 */ 2400 _config2.default.audio.addEventListener("seeked", function () { 2401 run("seeked"); 2402 }); 2403 2404 /* 2405 Event: seeking 2406 https://www.w3schools.com/tags/av_event_seeking.asp 2407 */ 2408 _config2.default.audio.addEventListener("seeking", function () { 2409 run("seeking"); 2410 }); 2411 2412 /* 2413 Event: stalled 2414 https://www.w3schools.com/tags/av_event_stalled.asp 2415 */ 2416 _config2.default.audio.addEventListener("stalled", function () { 2417 run("stalled"); 2418 }); 2419 2420 /* 2421 Event: suspend 2422 https://www.w3schools.com/tags/av_event_suspend.asp 2423 */ 2424 _config2.default.audio.addEventListener("suspend", function () { 2425 run("suspend"); 2426 }); 2427 2428 /* 2429 Event: timeupdate 2430 https://www.w3schools.com/tags/av_event_timeupdate.asp 2431 */ 2432 _config2.default.audio.addEventListener("timeupdate", function () { 2433 run("timeupdate"); 2434 }); 2435 2436 /* 2437 Event: volumechange 2438 https://www.w3schools.com/tags/av_event_volumechange.asp 2439 */ 2440 _config2.default.audio.addEventListener("volumechange", function () { 2441 run("volumechange"); 2442 }); 2443 2444 /* 2445 Event: waiting 2446 https://www.w3schools.com/tags/av_event_waiting.asp 2447 */ 2448 _config2.default.audio.addEventListener("waiting", function () { 2449 run("waiting"); 2450 }); 2451 2452 /* 2453 Event: canplay 2454 https://www.w3schools.com/tags/av_event_canplay.asp 2455 */ 2456 _config2.default.audio.addEventListener("canplay", function () { 2457 run("canplay"); 2458 }); 2459 2460 /* 2461 Event: canplaythrough 2462 https://www.w3schools.com/tags/av_event_canplaythrough.asp 2463 */ 2464 _config2.default.audio.addEventListener("canplaythrough", function () { 2465 run("canplaythrough"); 2466 }); 2467 2468 /* 2469 Event: durationchange 2470 https://www.w3schools.com/tags/av_event_durationchange.asp 2471 */ 2472 _config2.default.audio.addEventListener("durationchange", function () { 2473 run("durationchange"); 2474 }); 2475 2476 /* 2477 Event: ended 2478 https://www.w3schools.com/tags/av_event_ended.asp 2479 */ 2480 _config2.default.audio.addEventListener("ended", function () { 2481 run("ended"); 2482 }); 2483 } 2484 2485 /** 2486 * Runs a user defined callback method 2487 * 2488 * Public Accessor: Callbacks.run( callbackName ) 2489 * 2490 * @access public 2491 * @param {string} callbackName - The name of the callback we are going to run. 2492 */ 2493 function run(callbackName) { 2494 /* 2495 Checks to see if a user defined a callback method for the 2496 callback we are running. 2497 */ 2498 if (_config2.default.callbacks[callbackName]) { 2499 /* 2500 Build the callback function 2501 */ 2502 var callbackFunction = _config2.default.callbacks[callbackName]; 2503 2504 /* 2505 Write a debug message stating the callback we are running 2506 */ 2507 _debug2.default.writeMessage("Running Callback: " + callbackName); 2508 2509 /* 2510 Run the callback function and catch any errors 2511 */ 2512 try { 2513 callbackFunction(); 2514 } catch (error) { 2515 if (error.message == "CANCEL EVENT") { 2516 throw error; 2517 } else { 2518 _debug2.default.writeMessage("Callback error: " + error.message); 2519 } 2520 } 2521 } 2522 } 2523 2524 return { 2525 initialize: initialize, 2526 run: run 2527 }; 2528}(); 2529 2530/** 2531 * Imports the debug module 2532 * @module utilities/debug 2533 */ 2534exports.default = Callbacks; 2535module.exports = exports["default"]; 2536 2537/***/ }), 2538/* 10 */ 2539/***/ (function(module, exports, __webpack_require__) { 2540 2541"use strict"; 2542 2543 2544Object.defineProperty(exports, "__esModule", { 2545 value: true 2546}); 2547/** 2548 * Handles the visual state for all of the mute elements. 2549 * 2550 * @module visual/MuteElements 2551 */ 2552var MuteElements = function () { 2553 /** 2554 * Syncs mute for all of the mute buttons. This represents the 2555 * state of the player if it's muted or not. 2556 * 2557 * @access public 2558 * @param {string} state - The muted state of the player. 2559 */ 2560 function setMuted(state) { 2561 /* 2562 Get all of the mute buttons. 2563 */ 2564 var muteClasses = document.getElementsByClassName("amplitude-mute"); 2565 2566 /* 2567 Iterate over all of the mute classes. If the state of the player 2568 is not-muted then we add the amplitude-not-muted classe and remove 2569 the amplitude muted class otherwise we do the opposite. 2570 */ 2571 for (var i = 0; i < muteClasses.length; i++) { 2572 if (!state) { 2573 muteClasses[i].classList.add("amplitude-not-muted"); 2574 muteClasses[i].classList.remove("amplitude-muted"); 2575 } else { 2576 muteClasses[i].classList.remove("amplitude-not-muted"); 2577 muteClasses[i].classList.add("amplitude-muted"); 2578 } 2579 } 2580 } 2581 2582 return { 2583 setMuted: setMuted 2584 }; 2585}(); 2586 2587exports.default = MuteElements; 2588module.exports = exports["default"]; 2589 2590/***/ }), 2591/* 11 */ 2592/***/ (function(module, exports, __webpack_require__) { 2593 2594"use strict"; 2595 2596 2597Object.defineProperty(exports, "__esModule", { 2598 value: true 2599}); 2600 2601var _config = __webpack_require__(0); 2602 2603var _config2 = _interopRequireDefault(_config); 2604 2605function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2606 2607/** 2608 * Keeps the volume slider elements in sync. 2609 * @module visual/VolumeSliderElements 2610 */ 2611var VolumeSliderElements = function () { 2612 /** 2613 * Visually syncs the volume sliders so they are all the same if there 2614 * are more than one. 2615 * 2616 * @access public 2617 */ 2618 function sync() { 2619 var volumeSliders = document.getElementsByClassName("amplitude-volume-slider"); 2620 2621 /* 2622 Iterates over all of the volume sliders for the song, setting the value 2623 to the config value. 2624 */ 2625 for (var i = 0; i < volumeSliders.length; i++) { 2626 volumeSliders[i].value = _config2.default.audio.volume * 100; 2627 } 2628 } 2629 2630 /** 2631 * Returns the public facing methods 2632 */ 2633 return { 2634 sync: sync 2635 }; 2636}(); /** 2637 * Imports the config module 2638 * @module config 2639 */ 2640exports.default = VolumeSliderElements; 2641module.exports = exports["default"]; 2642 2643/***/ }), 2644/* 12 */ 2645/***/ (function(module, exports, __webpack_require__) { 2646 2647"use strict"; 2648 2649 2650Object.defineProperty(exports, "__esModule", { 2651 value: true 2652}); 2653 2654var _config = __webpack_require__(0); 2655 2656var _config2 = _interopRequireDefault(_config); 2657 2658function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2659 2660/** 2661 * AmplitudeJS Repeater utility. Handles setting the repeat for all scenarios. 2662 * 2663 * @module utilities/Repeater 2664 */ 2665var Repeater = function () { 2666 /** 2667 * Sets the state of the repeat for a song. 2668 * 2669 * @access public 2670 * @param {boolean} repeat - A boolean representing whether the repeat should be on or off 2671 */ 2672 function setRepeat(repeat) { 2673 /* 2674 Set the global repeat to be toggled 2675 */ 2676 _config2.default.repeat = repeat; 2677 } 2678 2679 /** 2680 * Sets the state of the repeat for a playlist. 2681 * 2682 * @access public 2683 * @param {boolean} repeat - A boolean representing whether the repeat should be on or off 2684 * @param {string} playlist - The key of the playlist for repeating 2685 */ 2686 function setRepeatPlaylist(repeat, playlist) { 2687 /* 2688 Set the playlist repeat to be toggled. 2689 */ 2690 _config2.default.playlists[playlist].repeat = repeat; 2691 } 2692 2693 /** 2694 * Sets the state of the repeat song 2695 * 2696 * @access public 2697 * @param {boolean} repeat - A boolean representing whether the repeat shoudl be on or off for the song. 2698 */ 2699 function setRepeatSong(repeat) { 2700 _config2.default.repeat_song = repeat; 2701 } 2702 2703 /* 2704 Returns the public facing methods 2705 */ 2706 return { 2707 setRepeat: setRepeat, 2708 setRepeatPlaylist: setRepeatPlaylist, 2709 setRepeatSong: setRepeatSong 2710 }; 2711}(); /** 2712 * Imports the config module 2713 * @module config 2714 */ 2715exports.default = Repeater; 2716module.exports = exports["default"]; 2717 2718/***/ }), 2719/* 13 */ 2720/***/ (function(module, exports, __webpack_require__) { 2721 2722"use strict"; 2723 2724 2725Object.defineProperty(exports, "__esModule", { 2726 value: true 2727}); 2728 2729var _config = __webpack_require__(0); 2730 2731var _config2 = _interopRequireDefault(_config); 2732 2733function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2734 2735/** 2736 * AmplitudeJS Shuffle Module. Handles all of the shuffling functionality for 2737 * AmplitudeJS 2738 * 2739 * @module utilities/Shuffler 2740 */ 2741var Shuffler = function () { 2742 /** 2743 * Sets the shuffle state globally 2744 * 2745 * @access public 2746 * @param {boolean} shuffle - True when we are shuffling, false when we turn it off. 2747 */ 2748 function setShuffle(shuffle) { 2749 _config2.default.shuffle_on = shuffle; 2750 2751 if (shuffle) { 2752 shuffleSongs(); 2753 } else { 2754 _config2.default.shuffle_list = []; 2755 } 2756 } 2757 2758 /** 2759 * Toggles the shuffle status globally. 2760 * 2761 * @access public 2762 */ 2763 function toggleShuffle() { 2764 /* 2765 If shuffle is on, we toggle it off. If shuffle is off, we 2766 toggle on. 2767 */ 2768 if (_config2.default.shuffle_on) { 2769 _config2.default.shuffle_on = false; 2770 _config2.default.shuffle_list = []; 2771 } else { 2772 _config2.default.shuffle_on = true; 2773 shuffleSongs(); 2774 } 2775 } 2776 2777 /** 2778 * Sets the shuffle state for a playlist 2779 * 2780 * @access public 2781 * @param {string} playlist The key of the playlist we are shuffling. 2782 * @param {boolean} shuffle True when we are shuffling the playlist, false when we turn off shuffle. 2783 */ 2784 function setShufflePlaylist(playlist, shuffle) { 2785 _config2.default.playlists[playlist].shuffle = shuffle; 2786 2787 if (_config2.default.playlists[playlist].shuffle) { 2788 shufflePlaylistSongs(playlist); 2789 } else { 2790 _config2.default.playlists[playlist].shuffle_list = []; 2791 } 2792 } 2793 2794 /** 2795 * Sets the shuffle state for a playlist 2796 * 2797 * @access public 2798 * @param {string} playlist The key of the playlist we are shuffling. 2799 */ 2800 function toggleShufflePlaylist(playlist) { 2801 /* 2802 If the playlist shuffled is on, we toggle it off. If the 2803 playlist shuffled is off, we toggle it on. 2804 */ 2805 if (_config2.default.playlists[playlist].shuffle) { 2806 _config2.default.playlists[playlist].shuffle = false; 2807 _config2.default.playlists[playlist].shuffle_list = []; 2808 } else { 2809 _config2.default.playlists[playlist].shuffle = true; 2810 shufflePlaylistSongs(playlist); 2811 } 2812 } 2813 2814 /** 2815 * Shuffles individual songs in the config 2816 * Based off of: http://www.codinghorror.com/blog/2007/12/the-danger-of-naivete.html 2817 * 2818 * Public Accessor: Shuffle.shuffleSongs() 2819 * 2820 * @access public 2821 */ 2822 function shuffleSongs() { 2823 /* 2824 Builds a temporary array with the length of the config. 2825 */ 2826 var shuffleTemp = new Array(_config2.default.songs.length); 2827 2828 /* 2829 Set the temporary array equal to the songs array. 2830 */ 2831 for (var i = 0; i < _config2.default.songs.length; i++) { 2832 shuffleTemp[i] = _config2.default.songs[i]; 2833 } 2834 2835 /* 2836 Iterate ove rthe songs and generate random numbers to 2837 swap the indexes of the shuffle array. 2838 */ 2839 for (var _i = _config2.default.songs.length - 1; _i > 0; _i--) { 2840 var randNum = Math.floor(Math.random() * _config2.default.songs.length + 1); 2841 shuffleSwap(shuffleTemp, _i, randNum - 1); 2842 } 2843 2844 /* 2845 Set the shuffle list to the shuffle temp. 2846 */ 2847 _config2.default.shuffle_list = shuffleTemp; 2848 } 2849 2850 /** 2851 * Shuffle songs in a playlist 2852 * 2853 * Public Accessor: Shuffle.shufflePlaylistSongs( playlist ) 2854 * 2855 * @access public 2856 * @param {string} playlist - The playlist we are shuffling. 2857 */ 2858 function shufflePlaylistSongs(playlist) { 2859 /* 2860 Builds a temporary array with the length of the playlist songs. 2861 */ 2862 var shuffleTemp = new Array(_config2.default.playlists[playlist].songs.length); 2863 2864 /* 2865 Set the temporary array equal to the playlist array. 2866 */ 2867 for (var i = 0; i < _config2.default.playlists[playlist].songs.length; i++) { 2868 shuffleTemp[i] = _config2.default.playlists[playlist].songs[i]; 2869 } 2870 2871 /* 2872 Iterate ove rthe songs and generate random numbers to 2873 swap the indexes of the shuffle array. 2874 */ 2875 for (var _i2 = _config2.default.playlists[playlist].songs.length - 1; _i2 > 0; _i2--) { 2876 var randNum = Math.floor(Math.random() * _config2.default.playlists[playlist].songs.length + 1); 2877 shuffleSwap(shuffleTemp, _i2, randNum - 1); 2878 } 2879 2880 /* 2881 Set the shuffle list to the shuffle temp. 2882 */ 2883 _config2.default.playlists[playlist].shuffle_list = shuffleTemp; 2884 } 2885 2886 /** 2887 * Swaps and randomizes the song shuffle. 2888 * 2889 * @access private 2890 * @param {object} shuffleList - The list of songs that is going to be shuffled 2891 * @param {number} original - The original index of he song in the songs array 2892 * @param {number} random - The randomized index that will be the new index of the song in the shuffle array. 2893 */ 2894 function shuffleSwap(shuffleList, original, random) { 2895 var temp = shuffleList[original]; 2896 shuffleList[original] = shuffleList[random]; 2897 shuffleList[random] = temp; 2898 } 2899 2900 /** 2901 * Returns public facing methods 2902 */ 2903 return { 2904 setShuffle: setShuffle, 2905 toggleShuffle: toggleShuffle, 2906 setShufflePlaylist: setShufflePlaylist, 2907 toggleShufflePlaylist: toggleShufflePlaylist, 2908 shuffleSongs: shuffleSongs, 2909 shufflePlaylistSongs: shufflePlaylistSongs 2910 }; 2911}(); /** 2912 * Imports the config module 2913 * @module config 2914 */ 2915exports.default = Shuffler; 2916module.exports = exports["default"]; 2917 2918/***/ }), 2919/* 14 */ 2920/***/ (function(module, exports, __webpack_require__) { 2921 2922"use strict"; 2923 2924 2925Object.defineProperty(exports, "__esModule", { 2926 value: true 2927}); 2928 2929var _config = __webpack_require__(0); 2930 2931var _config2 = _interopRequireDefault(_config); 2932 2933function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2934 2935/** 2936 * Defines the visual representation of AmplitudeJS song slider elements. 2937 * @module visual/SongSliderElements 2938 */ 2939var SongSliderElements = function () { 2940 /** 2941 * Syncs all of the song slider elements. 2942 * 2943 * @access public 2944 * @param {number} location - The location of the song as a percentage. 2945 * @param {string} playlist - The playlist we are setting the song slider for. 2946 * @param {number} songIndex - The index of the song we are adjusting the song slider for. 2947 */ 2948 function sync(location, playlist, songIndex) { 2949 syncMain(location); 2950 syncPlaylist(location, playlist); 2951 syncSong(location, songIndex); 2952 syncSongInPlaylist(location, playlist); 2953 } 2954 2955 /** 2956 * Syncs the main slider location 2957 * 2958 * @access public 2959 * @param {number} location - The location of the song as a percentage. 2960 */ 2961 function syncMain(location) { 2962 /* 2963 Ensure we have a location that's a number 2964 */ 2965 location = !isNaN(location) ? location : 0; 2966 2967 /* 2968 Gets the main song sliders 2969 */ 2970 var mainSongSliders = document.querySelectorAll(".amplitude-song-slider"); 2971 2972 /* 2973 Iterates over all of the main sliders and sets the value to the 2974 percentage of the song played. 2975 */ 2976 for (var i = 0; i < mainSongSliders.length; i++) { 2977 /* 2978 Grab the playlist and song attributes from the element. 2979 */ 2980 var playlist = mainSongSliders[i].getAttribute("data-amplitude-playlist"); 2981 var song = mainSongSliders[i].getAttribute("data-amplitude-song-index"); 2982 2983 /* 2984 This method is responsible for only the global elements, 2985 so we make sure there are no playlist or songs defined on 2986 the element. 2987 */ 2988 if (playlist == null && song == null) { 2989 mainSongSliders[i].value = location; 2990 } 2991 } 2992 } 2993 2994 /** 2995 * Syncs playlist song slider locations 2996 * 2997 * @access public 2998 * @param {number} location - The location of the song as a percentage. 2999 * @param {string} playlist - The playlist we are setting the song slider for. 3000 */ 3001 function syncPlaylist(location, playlist) { 3002 /* 3003 Ensure we have a location that's a number 3004 */ 3005 location = !isNaN(location) ? location : 0; 3006 3007 /* 3008 Gets the playlist song sliders 3009 */ 3010 var playlistSongSliders = document.querySelectorAll('.amplitude-song-slider[data-amplitude-playlist="' + playlist + '"]'); 3011 3012 /* 3013 Iterates over all of the playlist sliders and sets the value to the 3014 percentage of the song played. 3015 */ 3016 for (var i = 0; i < playlistSongSliders.length; i++) { 3017 /* 3018 Grab the playlist and song attributes from the element. 3019 */ 3020 var playlistAttribute = playlistSongSliders[i].getAttribute("data-amplitude-playlist"); 3021 var songAttribute = playlistSongSliders[i].getAttribute("data-amplitude-song-index"); 3022 3023 /* 3024 This method is responsible for only the playlist elements, 3025 so we make sure the playlist attribute matches what is passed 3026 in. 3027 */ 3028 if (playlistAttribute == playlist && songAttribute == null) { 3029 playlistSongSliders[i].value = location; 3030 } 3031 } 3032 } 3033 3034 /** 3035 * Syncs individual song slider locations 3036 * 3037 * @access public 3038 * @param {number} location - The location of the song as a percentage. 3039 * @param {number} songIndex - The index of the song we are adjusting the song slider for. 3040 */ 3041 function syncSong(location, songIndex) { 3042 /* 3043 We only want to sync song sliders if the playlist is null. 3044 */ 3045 if (_config2.default.active_playlist == null) { 3046 /* 3047 Ensure we have a location that's a number 3048 */ 3049 location = !isNaN(location) ? location : 0; 3050 3051 /* 3052 Gets the individual song sliders 3053 */ 3054 var songSliders = document.querySelectorAll('.amplitude-song-slider[data-amplitude-song-index="' + songIndex + '"]'); 3055 3056 /* 3057 Iterates over all of the individual song sliders and sets the value 3058 to the percentage of the song played. 3059 */ 3060 for (var i = 0; i < songSliders.length; i++) { 3061 /* 3062 Grab the playlist and song attributes from the element. 3063 */ 3064 var playlistAttribute = songSliders[i].getAttribute("data-amplitude-playlist"); 3065 var songAttribute = songSliders[i].getAttribute("data-amplitude-song-index"); 3066 3067 /* 3068 This method is responsible for only the playlist elements, 3069 so we make sure the playlist attribute matches what is passed 3070 in. 3071 */ 3072 if (playlistAttribute == null && songAttribute == songIndex) { 3073 songSliders[i].value = location; 3074 } 3075 } 3076 } 3077 } 3078 3079 /** 3080 * Syncs individual song slider locations 3081 * 3082 * @access public 3083 * @param {number} location - The location of the song as a percentage. 3084 * @param {string} playlist - The playlist we are setting the song slider for. 3085 */ 3086 function syncSongInPlaylist(location, playlist) { 3087 /* 3088 Ensure we have a location that's a number 3089 */ 3090 location = !isNaN(location) ? location : 0; 3091 3092 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 3093 3094 /* 3095 Gets the song in playlist sliders 3096 */ 3097 var songInPlaylistSliders = document.querySelectorAll('.amplitude-song-slider[data-amplitude-playlist="' + playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 3098 3099 /* 3100 Iterates over all of the song in playlist sliders and sets the value 3101 to the percentage of the song played. 3102 */ 3103 for (var i = 0; i < songInPlaylistSliders.length; i++) { 3104 songInPlaylistSliders[i].value = location; 3105 } 3106 } 3107 3108 /** 3109 * Visually syncs the song sliders back to 0. This usually happens when 3110 * a song has changed, we ensure that all song sliders get reset. 3111 * 3112 * @access public 3113 */ 3114 function resetElements() { 3115 var songSliders = document.getElementsByClassName("amplitude-song-slider"); 3116 3117 /* 3118 Iterate over all of the song sliders and set them to 3119 0 essentially resetting them. 3120 */ 3121 for (var i = 0; i < songSliders.length; i++) { 3122 songSliders[i].value = 0; 3123 } 3124 } 3125 3126 /** 3127 * Returns the public facing methods 3128 */ 3129 return { 3130 sync: sync, 3131 syncMain: syncMain, 3132 syncPlaylist: syncPlaylist, 3133 syncSong: syncSong, 3134 syncSongInPlaylist: syncSongInPlaylist, 3135 resetElements: resetElements 3136 }; 3137}(); /** 3138 * Imports the config module 3139 * @module config 3140 */ 3141exports.default = SongSliderElements; 3142module.exports = exports["default"]; 3143 3144/***/ }), 3145/* 15 */ 3146/***/ (function(module, exports, __webpack_require__) { 3147 3148"use strict"; 3149 3150 3151Object.defineProperty(exports, "__esModule", { 3152 value: true 3153}); 3154 3155var _currentTimeElements = __webpack_require__(53); 3156 3157var _currentTimeElements2 = _interopRequireDefault(_currentTimeElements); 3158 3159var _currentHourElements = __webpack_require__(50); 3160 3161var _currentHourElements2 = _interopRequireDefault(_currentHourElements); 3162 3163var _currentMinuteElements = __webpack_require__(51); 3164 3165var _currentMinuteElements2 = _interopRequireDefault(_currentMinuteElements); 3166 3167var _currentSecondElements = __webpack_require__(52); 3168 3169var _currentSecondElements2 = _interopRequireDefault(_currentSecondElements); 3170 3171var _durationCountDownTimeElements = __webpack_require__(54); 3172 3173var _durationCountDownTimeElements2 = _interopRequireDefault(_durationCountDownTimeElements); 3174 3175var _durationHourElements = __webpack_require__(55); 3176 3177var _durationHourElements2 = _interopRequireDefault(_durationHourElements); 3178 3179var _durationMinuteElements = __webpack_require__(56); 3180 3181var _durationMinuteElements2 = _interopRequireDefault(_durationMinuteElements); 3182 3183var _durationSecondElements = __webpack_require__(57); 3184 3185var _durationSecondElements2 = _interopRequireDefault(_durationSecondElements); 3186 3187var _durationTimeElements = __webpack_require__(58); 3188 3189var _durationTimeElements2 = _interopRequireDefault(_durationTimeElements); 3190 3191function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3192 3193/** 3194 * Time Elements Interface. This allows us to update all of the sub time elements 3195 * through one central point. 3196 * @module visual/TimeElements 3197 */ 3198 3199 3200/** 3201 * Imports the AmplitudeJS Duration Second Elements 3202 * @module visual/time/DurationSecondElements 3203 */ 3204 3205 3206/** 3207 * Imports the AmplitudeJS Duration Hour Elements 3208 * @module visual/time/DurationHourElements 3209 */ 3210 3211 3212/** 3213 * Imports the AmplitudeJS Current Second Elements 3214 * @module visual/time/CurrentTimeElements 3215 */ 3216 3217 3218/** 3219 * Imports the AmplitudeJS Current Hour Elements 3220 * @module visual/time/CurrentHourElements 3221 */ 3222var TimeElements = function () { 3223 /** 3224 * Resets the current times. 3225 */ 3226 function resetCurrentTimes() { 3227 _currentTimeElements2.default.resetTimes(); 3228 _currentHourElements2.default.resetTimes(); 3229 _currentMinuteElements2.default.resetTimes(); 3230 _currentSecondElements2.default.resetTimes(); 3231 } 3232 3233 /** 3234 * Syncs the current time elements to the time provided. 3235 * 3236 * @param {Object} currentTime - An object representing the current time of the audio. 3237 */ 3238 function syncCurrentTimes(currentTime) { 3239 _currentTimeElements2.default.sync(currentTime); 3240 _currentHourElements2.default.sync(currentTime.hours); 3241 _currentMinuteElements2.default.sync(currentTime.minutes); 3242 _currentSecondElements2.default.sync(currentTime.seconds); 3243 } 3244 3245 /** 3246 * Resets the duration times. 3247 */ 3248 function resetDurationTimes() { 3249 _durationCountDownTimeElements2.default.resetTimes(); 3250 _durationHourElements2.default.resetTimes(); 3251 _durationMinuteElements2.default.resetTimes(); 3252 _durationSecondElements2.default.resetTimes(); 3253 _durationTimeElements2.default.resetTimes(); 3254 } 3255 3256 /** 3257 * Syncs the duration times to the times provided. 3258 * 3259 * @param {Object} currentTime - An object representing the current time of the audio. 3260 * @param {Object} songDuration - An object representing the duration of the audio 3261 */ 3262 function syncDurationTimes(currentTime, songDuration) { 3263 _durationCountDownTimeElements2.default.sync(currentTime, songDuration); 3264 _durationTimeElements2.default.sync(songDuration); 3265 _durationHourElements2.default.sync(songDuration.hours); 3266 _durationMinuteElements2.default.sync(songDuration.minutes); 3267 _durationSecondElements2.default.sync(songDuration.seconds); 3268 } 3269 3270 /** 3271 * Returns the publically accessible methods. 3272 */ 3273 return { 3274 resetCurrentTimes: resetCurrentTimes, 3275 syncCurrentTimes: syncCurrentTimes, 3276 resetDurationTimes: resetDurationTimes, 3277 syncDurationTimes: syncDurationTimes 3278 }; 3279}(); 3280 3281/** 3282 * Imports the AmplitudeJS Duration Time Elements 3283 * @module visual/time/DurationTimeElements 3284 */ 3285 3286 3287/** 3288 * Imports the AmplitudeJS Duration Minute Elements 3289 * @module visual/time/DurationMinuteElements 3290 */ 3291 3292 3293/** 3294 * Imports the AmplitudeJS Duration Count Down Time Elements 3295 * @module visual/time/DurationCountDownTimeElements 3296 */ 3297 3298 3299/** 3300 * Imports the AmplitudeJS Current Minute Elements 3301 * @module visual/time/CurrentMinuteElements 3302 */ 3303/** 3304 * Imports the AmplitudeJS Current Time 3305 * @module visual/time/CurrentTimeElements 3306 */ 3307exports.default = TimeElements; 3308module.exports = exports["default"]; 3309 3310/***/ }), 3311/* 16 */ 3312/***/ (function(module, exports, __webpack_require__) { 3313 3314"use strict"; 3315 3316 3317Object.defineProperty(exports, "__esModule", { 3318 value: true 3319}); 3320 3321var _config = __webpack_require__(0); 3322 3323var _config2 = _interopRequireDefault(_config); 3324 3325var _debug = __webpack_require__(4); 3326 3327var _debug2 = _interopRequireDefault(_debug); 3328 3329function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3330 3331/** 3332 * Handles the visualizations elements. 3333 * 3334 * @module Visualizations 3335 */ 3336/** 3337 * Imports the config module 3338 * @module config 3339 */ 3340var Visualizations = function () { 3341 /** 3342 * Runs all of the visualizations on the screen. 3343 */ 3344 function run() { 3345 /* 3346 Get all of the visualization elements on the page 3347 */ 3348 var visualizationElements = document.querySelectorAll(".amplitude-visualization"); 3349 3350 /* 3351 If the web audio API is available, we display the visualizations. 3352 */ 3353 if (_config2.default.web_audio_api_available) { 3354 /* 3355 If the visualization has not started, there are visualizations available, 3356 and we have at least one visualization element, then we continue. 3357 */ 3358 if (Object.keys(_config2.default.visualizations.available).length > 0 && visualizationElements.length > 0) { 3359 /* 3360 Iterate over all of the visualizations on the page and activate the 3361 ones we need. 3362 */ 3363 for (var i = 0; i < visualizationElements.length; i++) { 3364 /* 3365 Grab the playlist and song attributes from the visualization to 3366 determine which one we run. 3367 */ 3368 var playlist = visualizationElements[i].getAttribute("data-amplitude-playlist"); 3369 var song = visualizationElements[i].getAttribute("data-amplitude-song-index"); 3370 3371 /* 3372 If the playlist and song are null, it's a global visualization element. 3373 */ 3374 if (playlist == null && song == null) { 3375 runGlobalVisualization(visualizationElements[i]); 3376 } 3377 3378 /* 3379 if the playlist is not null and the song is null it's a playlist visualization 3380 element. 3381 */ 3382 if (playlist != null && song == null) { 3383 runPlaylistVisualization(visualizationElements[i], playlist); 3384 } 3385 3386 /* 3387 If the playlist is null and the song is not null it's a song visualization element. 3388 */ 3389 if (playlist == null && song != null) { 3390 runSongVisualization(visualizationElements[i], song); 3391 } 3392 3393 /* 3394 If the playlist and song are not null then it's a song in playlist visualization 3395 element. 3396 */ 3397 if (playlist != null && song != null) { 3398 runSongInPlaylistVisualization(visualizationElements[i], playlist, song); 3399 } 3400 } 3401 } 3402 } else { 3403 displayBackups(); 3404 } 3405 } 3406 3407 /** 3408 * Runs a global visualization 3409 * 3410 * @param {Node} element The container element that handles the visualization. 3411 */ 3412 function runGlobalVisualization(element) { 3413 /* 3414 Gets the global visualization index and the active song visualization indexes 3415 so we know which visualization to use. The song will override the global 3416 */ 3417 var globalVisualizationIndex = _config2.default.visualization; 3418 var activeSongVisualizationIndex = _config2.default.active_index != null ? _config2.default.songs[_config2.default.active_index].visualization : _config2.default.playlists[_config2.default.active_playlist].songs[_config2.default.playlists[_config2.default.active_playlist].active_index].visualization; 3419 3420 /* 3421 If the active song visualization is defined and the visualization exists, 3422 use that visualization. 3423 */ 3424 if (activeSongVisualizationIndex != undefined && _config2.default.visualizations.available[activeSongVisualizationIndex] != undefined) { 3425 addToActiveVisualizations(activeSongVisualizationIndex, element); 3426 3427 /* 3428 If the user defined a global visualization, use that one. 3429 */ 3430 } else if (globalVisualizationIndex != undefined && _config2.default.visualizations.available[globalVisualizationIndex] != undefined) { 3431 addToActiveVisualizations(globalVisualizationIndex, element); 3432 3433 /* 3434 If the user didn't define a global visualization, use the first visualization 3435 registered if there is one. 3436 */ 3437 } else { 3438 /* 3439 Grab the first registered visualization. If it exists, use that one. 3440 */ 3441 var firstVisualization = Object.keys(_config2.default.visualizations.available).length > 0 ? Object.keys(_config2.default.visualizations.available)[0] : null; 3442 3443 if (firstVisualization != null) { 3444 addToActiveVisualizations(firstVisualization, element); 3445 } 3446 } 3447 } 3448 3449 /** 3450 * Run a specific playlist visualization. 3451 * 3452 * @param {Node} element The container element that handles the visualization. 3453 * @param {string} playlist The key of the playlist we are running the visualization for. 3454 */ 3455 function runPlaylistVisualization(element, playlist) { 3456 /* 3457 If the playlist is equal to the active playlist, then we continue. 3458 */ 3459 if (playlist == _config2.default.active_playlist) { 3460 /* 3461 Checks if the song has a visualization and that visualization exists, 3462 run that visualization. 3463 */ 3464 var activeSongVisualizationIndex = _config2.default.playlists[_config2.default.active_playlist].songs[_config2.default.playlists[_config2.default.active_playlist].active_index].visualization; 3465 var activePlaylistVisualizationIndex = _config2.default.playlists[_config2.default.active_playlist].visualization; 3466 var globalVisualizationIndex = _config2.default.visualization; 3467 3468 /* 3469 If the actual song has a visualization, we run that. 3470 */ 3471 if (activeSongVisualizationIndex != undefined && _config2.default.visualizations.available[activeSongVisualizationIndex] != undefined) { 3472 addToActiveVisualizations(activeSongVisualizationIndex, element); 3473 3474 /* 3475 If the actual playlist has a visualization, run that. 3476 */ 3477 } else if (activePlaylistVisualizationIndex != undefined && _config2.default.visualizations.available[activePlaylistVisualizationIndex] != undefined) { 3478 addToActiveVisualizations(activePlaylistVisualizationIndex, element); 3479 3480 /* 3481 If a global visualization is defined, run that. 3482 */ 3483 } else if (globalVisualizationIndex != undefined && _config2.default.visualizations.available[globalVisualizationIndex] != undefined) { 3484 addToActiveVisualizations(globalVisualizationIndex, element); 3485 } else { 3486 /* 3487 Grab the first registered visualization. If it exists, use that one. 3488 */ 3489 var firstVisualization = Object.keys(_config2.default.visualizations.available).length > 0 ? Object.keys(_config2.default.visualizations.available)[0] : null; 3490 3491 if (firstVisualization != null) { 3492 addToActiveVisualizations(firstVisualization, element); 3493 } 3494 } 3495 } 3496 } 3497 3498 /** 3499 * Run a song specific visualization. 3500 * 3501 * @param {Node} element The container element that handles the visualization. 3502 * @param {string} song The song index that we are running the visualization for. 3503 */ 3504 function runSongVisualization(element, song) { 3505 /* 3506 If the song is equal to the active song, then we continue. 3507 */ 3508 if (song == _config2.default.active_index) { 3509 /* 3510 Get the indexes of the song 3511 */ 3512 var activeSongVisualizationIndex = _config2.default.songs[_config2.default.active_index].visualization; 3513 var globalVisualizationIndex = _config2.default.visualization; 3514 3515 /* 3516 If the song has a visualization, run that. 3517 */ 3518 if (activeSongVisualizationIndex != undefined && _config2.default.visualizations.available[activeSongVisualizationIndex] != undefined) { 3519 addToActiveVisualizations(activeSongVisualizationIndex, element); 3520 3521 /* 3522 If the global visualization is set, use that. 3523 */ 3524 } else if (globalVisualizationIndex != undefined && _config2.default.visualizations.available[globalVisualizationIndex] != undefined) { 3525 addToActiveVisualizations(globalVisualizationIndex, element); 3526 } else { 3527 /* 3528 Grab the first registered visualization. If it exists, use that one. 3529 */ 3530 var firstVisualization = Object.keys(_config2.default.visualizations.available).length > 0 ? Object.keys(_config2.default.visualizations.available)[0] : null; 3531 3532 if (firstVisualization != null) { 3533 addToActiveVisualizations(firstVisualization, element); 3534 } 3535 } 3536 } 3537 } 3538 3539 /** 3540 * Run a song in playlist visualization. 3541 * 3542 * @param {Node} element - The element containing the visualization. 3543 * @param {string} playlist - The string of the playlist key. 3544 * @param {index} song - The index of the song in the playlist. 3545 */ 3546 function runSongInPlaylistVisualization(element, playlist, song) { 3547 /* 3548 If the playlist is the same as the active playlist and the active 3549 index of the song is the same as the song, then we continue. 3550 */ 3551 if (playlist == _config2.default.active_playlist && _config2.default.playlists[playlist].active_index == song) { 3552 /* 3553 Checks if the song has a visualization and that visualization exists, 3554 run that visualization. 3555 */ 3556 var activeSongVisualizationIndex = _config2.default.playlists[_config2.default.active_playlist].songs[_config2.default.playlists[_config2.default.active_playlist].active_index].visualization; 3557 var activePlaylistVisualizationIndex = _config2.default.playlists[_config2.default.active_playlist].visualization; 3558 var globalVisualizationIndex = _config2.default.visualization; 3559 3560 /* 3561 If the active song has a visualization, we use that. 3562 */ 3563 if (activeSongVisualizationIndex != undefined && _config2.default.visualizations.available[activeSongVisualizationIndex] != undefined) { 3564 addToActiveVisualizations(activeSongVisualizationIndex, element); 3565 3566 /* 3567 If the active playlist has a visualization, we use that. 3568 */ 3569 } else if (activePlaylistVisualizationIndex != undefined && _config2.default.visualizations.available[activePlaylistVisualizationIndex] != undefined) { 3570 addToActiveVisualizations(activePlaylistVisualizationIndex, element); 3571 3572 /* 3573 If the global visualization has been set, we use that. 3574 */ 3575 } else if (globalVisualizationIndex != undefined && _config2.default.visualizations.available[globalVisualizationIndex] != undefined) { 3576 addToActiveVisualizations(globalVisualizationIndex, element); 3577 } else { 3578 /* 3579 Grab the first registered visualization. If it exists, use that one. 3580 */ 3581 var firstVisualization = Object.keys(_config2.default.visualizations.available).length > 0 ? Object.keys(_config2.default.visualizations.available)[0] : null; 3582 3583 if (firstVisualization != null) { 3584 addToActiveVisualizations(firstVisualization, element); 3585 } 3586 } 3587 } 3588 } 3589 3590 /** 3591 * Add a visualization to the array of active visualizations. 3592 * 3593 * @param {string} key - The key of the active visualization. 3594 * @param {Node} element - The element that the visualization will be applied to. 3595 */ 3596 function addToActiveVisualizations(key, element) { 3597 var visualization = new _config2.default.visualizations.available[key]["object"](); 3598 visualization.setPreferences(_config2.default.visualizations.available[key]["preferences"]); 3599 visualization.startVisualization(element); 3600 _config2.default.visualizations.active.push(visualization); 3601 } 3602 3603 /** 3604 * Stops all active visualizations. 3605 */ 3606 function stop() { 3607 /* 3608 Iterates over all of the visualizations and stop the visualization. 3609 */ 3610 for (var i = 0; i < _config2.default.visualizations.active.length; i++) { 3611 _config2.default.visualizations.active[i].stopVisualization(); 3612 } 3613 3614 /* 3615 Clear the active visualizations. 3616 */ 3617 _config2.default.visualizations.active = []; 3618 } 3619 3620 /** 3621 * Registers any visualization we can use. 3622 * 3623 * @param {object} visualization The visualization object itself 3624 * @param {object} preferences User preferences overrides. 3625 */ 3626 function register(visualization, preferences) { 3627 /* 3628 Initialize the new visualization. 3629 */ 3630 var newVisualization = new visualization(); 3631 3632 /* 3633 Adds the visualization to the global config so it knows 3634 it can be used when playing songs. 3635 getID is a public function for getting a visualization's id. 3636 It becomes the key to access the visualization. 3637 */ 3638 _config2.default.visualizations.available[newVisualization.getID()] = new Array(); 3639 _config2.default.visualizations.available[newVisualization.getID()]["object"] = visualization; 3640 _config2.default.visualizations.available[newVisualization.getID()]["preferences"] = preferences; 3641 } 3642 3643 /** 3644 * Displays the backups for the visualizations. 3645 */ 3646 function displayBackups() { 3647 /* 3648 Get all of the visualization elements on the page 3649 */ 3650 var visualizationElements = document.querySelectorAll(".amplitude-visualization"); 3651 3652 if (visualizationElements.length > 0) { 3653 for (var x = 0; x < visualizationElements.length; x++) { 3654 /* 3655 Grab the playlist and song attributes from the visualization to 3656 determine which one we run. 3657 */ 3658 var playlist = visualizationElements[x].getAttribute("data-amplitude-playlist"); 3659 var song = visualizationElements[x].getAttribute("data-amplitude-song-index"); 3660 3661 /* 3662 If the playlist and song are null, it's a global visualization element. 3663 */ 3664 if (playlist == null && song == null) { 3665 displayGlobalBackup(visualizationElements[x]); 3666 } 3667 3668 /* 3669 if the playlist is not null and the song is null it's a playlist visualization 3670 element. 3671 */ 3672 if (playlist != null && song == null) { 3673 displayPlaylistBackup(visualizationElements[x], playlist); 3674 } 3675 3676 /* 3677 If the playlist is null and the song is not null it's a song visualization element. 3678 */ 3679 if (playlist == null && song != null) { 3680 displaySongBackup(visualizationElements[x], song); 3681 } 3682 3683 /* 3684 If the playlist and song are not null then it's a song in playlist visualization 3685 element. 3686 */ 3687 if (playlist != null && song != null) { 3688 displaySongInPlaylistBackup(visualizationElements[x], playlist, song); 3689 } 3690 } 3691 } 3692 } 3693 3694 /** 3695 * Displays the global backup which is the cover art of the image in the 3696 * visualization container. 3697 * 3698 * @param {node} element - The element we are adding the background image to. 3699 */ 3700 function displayGlobalBackup(element) { 3701 element.style.backgroundImage = "url(" + _config2.default.active_metadata.cover_art_url + ")"; 3702 } 3703 3704 /** 3705 * Displays the playlist backup which is the cover art of the image in the 3706 * visualization container. 3707 * 3708 * @param {node} element - The element we are adding the background image to. 3709 */ 3710 function displayPlaylistBackup(element, playlist) { 3711 if (_config2.default.active_playlist == playlist) { 3712 element.style.backgroundImage = "url(" + _config2.default.active_metadata.cover_art_url + ")"; 3713 } 3714 } 3715 3716 /** 3717 * Displays the song backup which is the cover art of the image in the 3718 * visualization container. 3719 * 3720 * @param {node} element - The element we are adding the background image to. 3721 */ 3722 function displaySongBackup(element, song) { 3723 if (_config2.default.active_index == song) { 3724 element.style.backgroundImage = "url(" + _config2.default.active_metadata.cover_art_url + ")"; 3725 } 3726 } 3727 3728 /** 3729 * Displays the song in playlist backup which is the cover art of the image in the 3730 * visualization container. 3731 * 3732 * @param {node} element - The element we are adding the background image to. 3733 */ 3734 function displaySongInPlaylistBackup(element, playlist, song) { 3735 if (_config2.default.active_playlist == playlist && _config2.default.playlists[active_playlist].active_index == song) { 3736 element.style.backgroundImage = "url(" + _config2.default.active_metadata.cover_art_url + ")"; 3737 } 3738 } 3739 3740 /* 3741 Returns the public facing methods 3742 */ 3743 return { 3744 run: run, 3745 stop: stop, 3746 register: register 3747 }; 3748}(); 3749 3750/** 3751 * Imports the debug module 3752 * @module utilities/Debug 3753 */ 3754exports.default = Visualizations; 3755module.exports = exports["default"]; 3756 3757/***/ }), 3758/* 17 */ 3759/***/ (function(module, exports, __webpack_require__) { 3760 3761"use strict"; 3762 3763 3764Object.defineProperty(exports, "__esModule", { 3765 value: true 3766}); 3767 3768var _config = __webpack_require__(0); 3769 3770var _config2 = _interopRequireDefault(_config); 3771 3772var _init = __webpack_require__(21); 3773 3774var _init2 = _interopRequireDefault(_init); 3775 3776function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3777 3778/** 3779 * These helpers wrap around the basic methods of the Soundcloud API 3780 * and get the information we need from SoundCloud to make the songs 3781 * streamable through Amplitude 3782 * 3783 * @module soundcloud/SoundCloud 3784 */ 3785/** 3786 * Imports the config module 3787 * @module config 3788 */ 3789var SoundCloud = function () { 3790 /** 3791 * Defines the temporary user config used while we configure soundcloud 3792 * @type {object} 3793 */ 3794 var tempUserConfig = {}; 3795 3796 /** 3797 * Loads the soundcloud SDK for use with Amplitude so the user doesn't have 3798 * to load it themselves. 3799 * With help from: http://stackoverflow.com/questions/950087/include-a-javascript-file-in-another-javascript-file 3800 * 3801 * @access public 3802 * @param {object} userConfig - The config defined by the user for AmplitudeJS 3803 */ 3804 function loadSoundCloud(userConfig) { 3805 /* 3806 Sets the temporary config to the config passed by the user so we can make changes 3807 and not break the actual config. 3808 */ 3809 tempUserConfig = userConfig; 3810 3811 /* 3812 Gets the head tag for the document and create a script element. 3813 */ 3814 var head = document.getElementsByTagName("head")[0]; 3815 var script = document.createElement("script"); 3816 3817 script.type = "text/javascript"; 3818 3819 /* 3820 URL to the remote soundcloud SDK 3821 */ 3822 script.src = "https://connect.soundcloud.com/sdk.js"; 3823 script.onreadystatechange = initSoundcloud; 3824 script.onload = initSoundcloud; 3825 3826 /* 3827 Add the script to the head of the document. 3828 */ 3829 head.appendChild(script); 3830 } 3831 3832 /** 3833 * Initializes soundcloud with the key provided. 3834 * 3835 * @access private 3836 */ 3837 function initSoundcloud() { 3838 /* 3839 Calls the SoundCloud initialize function 3840 from their API and sends it the client_id 3841 that the user passed in. 3842 */ 3843 SC.initialize({ 3844 client_id: _config2.default.soundcloud_client 3845 }); 3846 3847 /* 3848 Gets the streamable URLs to run through Amplitue. This is 3849 VERY important since Amplitude can't stream the copy and pasted 3850 link from the SoundCloud page, but can resolve the streaming 3851 URLs from the link. 3852 */ 3853 getStreamableURLs(); 3854 } 3855 3856 /** 3857 * Gets the streamable URL from the URL provided for 3858 * all of the soundcloud links. This will loop through 3859 * and set all of the information for the soundcloud 3860 * urls. 3861 * 3862 * @access private 3863 */ 3864 function getStreamableURLs() { 3865 /* 3866 Define the regex to find the soundcloud URLs 3867 */ 3868 var soundcloud_regex = /^https?:\/\/(soundcloud.com|snd.sc)\/(.*)$/; 3869 3870 for (var i = 0; i < _config2.default.songs.length; i++) { 3871 /* 3872 If the URL matches soundcloud, we grab 3873 that url and get the streamable link 3874 if there is one. 3875 */ 3876 if (_config2.default.songs[i].url.match(soundcloud_regex)) { 3877 _config2.default.soundcloud_song_count++; 3878 resolveStreamable(_config2.default.songs[i].url, i); 3879 } 3880 } 3881 } 3882 3883 /** 3884 * Resolves an individual streamable URL. 3885 * 3886 * @param {string} url - The URL of the SoundCloud song to get the streamable URL from. 3887 * @param {string} playlist - The playlist we are getting the streamable URL for. 3888 * @param {Integer} index - The index of the song in the playlist or the songs array. 3889 * @param {boolean} addToShuffleList - Whether we add to the shuffle list for the songs or playlist. 3890 * 3891 */ 3892 function resolveIndividualStreamableURL(url, playlist, index) { 3893 var addToShuffleList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 3894 3895 SC.get("/resolve/?url=" + url, function (sound) { 3896 /* 3897 If streamable we get the url and bind the client ID to the end 3898 so Amplitude can just stream the song normally. We then overwrite 3899 the url the user provided with the streamable URL. 3900 */ 3901 if (sound.streamable) { 3902 if (playlist != null) { 3903 _config2.default.playlists[playlist].songs[index].url = sound.stream_url + "?client_id=" + _config2.default.soundcloud_client; 3904 3905 if (addToShuffleList) { 3906 _config2.default.playlists[playlist].shuffle_list[index].url = sound.stream_url + "?client_id=" + _config2.default.soundcloud_client; 3907 } 3908 /* 3909 If the user want's to use soundcloud art, we overwrite the 3910 cover_art_url with the soundcloud artwork url. 3911 */ 3912 if (_config2.default.soundcloud_use_art) { 3913 _config2.default.playlists[playlist].songs[index].cover_art_url = sound.artwork_url; 3914 3915 if (addToShuffleList) { 3916 _config2.default.playlists[playlist].shuffle_list[index].cover_art_url = sound.artwork_url; 3917 } 3918 } 3919 3920 /* 3921 Grab the extra metadata from soundcloud and bind it to the 3922 song. The user can get this through the public function: 3923 getActiveSongMetadata 3924 */ 3925 _config2.default.playlists[playlist].songs[index].soundcloud_data = sound; 3926 3927 if (addToShuffleList) { 3928 _config2.default.playlists[playlist].shuffle_list[index].soundcloud_data = sound; 3929 } 3930 } else { 3931 _config2.default.songs[index].url = sound.stream_url + "?client_id=" + _config2.default.soundcloud_client; 3932 3933 if (addToShuffleList) { 3934 _config2.default.shuffle_list[index].stream_url + "?client_id=" + _config2.default.soundcloud_client; 3935 } 3936 3937 /* 3938 If the user want's to use soundcloud art, we overwrite the 3939 cover_art_url with the soundcloud artwork url. 3940 */ 3941 if (_config2.default.soundcloud_use_art) { 3942 _config2.default.songs[index].cover_art_url = sound.artwork_url; 3943 3944 if (addToShuffleList) { 3945 _config2.default.shuffle_list[index].cover_art_url = sound.artwork_url; 3946 } 3947 } 3948 3949 /* 3950 Grab the extra metadata from soundcloud and bind it to the 3951 song. The user can get this through the public function: 3952 getActiveSongMetadata 3953 */ 3954 _config2.default.songs[index].soundcloud_data = sound; 3955 3956 if (addToShuffleList) { 3957 _config2.default.shuffle_list[index].soundcloud_data = sound; 3958 } 3959 } 3960 } else { 3961 if (playlist != null) { 3962 AmplitudeHelpers.writeDebugMessage(_config2.default.playlists[playlist].songs[index].name + " by " + _config2.default.playlists[playlist].songs[index].artist + " is not streamable by the Soundcloud API"); 3963 } else { 3964 /* 3965 If not streamable, then we print a message to the user stating 3966 that the song with name X and artist X is not streamable. This 3967 gets printed ONLY if they have debug turned on. 3968 */ 3969 AmplitudeHelpers.writeDebugMessage(_config2.default.songs[index].name + " by " + _config2.default.songs[index].artist + " is not streamable by the Soundcloud API"); 3970 } 3971 } 3972 }); 3973 } 3974 3975 /** 3976 * Due to Soundcloud SDK being asynchronous, we need to scope the 3977 * index of the song in another function. The privateGetSoundcloudStreamableURLs 3978 * function does the actual iteration and scoping. 3979 * 3980 * @access private 3981 * @param {string} url - URL of the soundcloud song 3982 * @param {number} index - The index of the soundcloud song in the songs array. 3983 */ 3984 function resolveStreamable(url, index) { 3985 SC.get("/resolve/?url=" + url, function (sound) { 3986 /* 3987 If streamable we get the url and bind the client ID to the end 3988 so Amplitude can just stream the song normally. We then overwrite 3989 the url the user provided with the streamable URL. 3990 */ 3991 if (sound.streamable) { 3992 _config2.default.songs[index].url = sound.stream_url + "?client_id=" + _config2.default.soundcloud_client; 3993 3994 /* 3995 If the user want's to use soundcloud art, we overwrite the 3996 cover_art_url with the soundcloud artwork url. 3997 */ 3998 if (_config2.default.soundcloud_use_art) { 3999 _config2.default.songs[index].cover_art_url = sound.artwork_url; 4000 } 4001 4002 /* 4003 Grab the extra metadata from soundcloud and bind it to the 4004 song. The user can get this through the public function: 4005 getActiveSongMetadata 4006 */ 4007 _config2.default.songs[index].soundcloud_data = sound; 4008 } else { 4009 /* 4010 If not streamable, then we print a message to the user stating 4011 that the song with name X and artist X is not streamable. This 4012 gets printed ONLY if they have debug turned on. 4013 */ 4014 AmplitudeHelpers.writeDebugMessage(_config2.default.songs[index].name + " by " + _config2.default.songs[index].artist + " is not streamable by the Soundcloud API"); 4015 } 4016 /* 4017 Increments the song ready counter. 4018 */ 4019 _config2.default.soundcloud_songs_ready++; 4020 4021 /* 4022 When all songs are accounted for, then amplitude is ready 4023 to rock and we set the rest of the config. 4024 */ 4025 if (_config2.default.soundcloud_songs_ready == _config2.default.soundcloud_song_count) { 4026 _init2.default.setConfig(tempUserConfig); 4027 } 4028 }); 4029 } 4030 4031 /** 4032 * Determines if a given URL is a SoundCloud URL. 4033 * 4034 * @param {string} url - The URL to test if it's a SoundCloud URL. 4035 */ 4036 function isSoundCloudURL(url) { 4037 var soundcloud_regex = /^https?:\/\/(soundcloud.com|snd.sc)\/(.*)$/; 4038 4039 return url.match(soundcloud_regex); 4040 } 4041 4042 /* 4043 Returns the publically accessible methods 4044 */ 4045 return { 4046 loadSoundCloud: loadSoundCloud, 4047 resolveIndividualStreamableURL: resolveIndividualStreamableURL, 4048 isSoundCloudURL: isSoundCloudURL 4049 }; 4050}(); 4051 4052/** 4053 * Imports the initializer 4054 * @module init/AmplitudeInitializer 4055 */ 4056exports.default = SoundCloud; 4057module.exports = exports["default"]; 4058 4059/***/ }), 4060/* 18 */ 4061/***/ (function(module, exports, __webpack_require__) { 4062 4063"use strict"; 4064 4065 4066Object.defineProperty(exports, "__esModule", { 4067 value: true 4068}); 4069 4070var _config = __webpack_require__(0); 4071 4072var _config2 = _interopRequireDefault(_config); 4073 4074function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4075 4076/** 4077 * Defines the Playback Speed Visual Elements Handler 4078 * @module visual/PlaybackSpeedElements 4079 */ 4080var PlaybackSpeedElements = function () { 4081 /** 4082 * Sets all of the visual playback speed buttons to have the right class 4083 * to display the background image that represents the current playback 4084 * speed. 4085 * 4086 * @access public 4087 */ 4088 function sync() { 4089 /* 4090 Gets all of the playback speed classes. 4091 */ 4092 var playbackSpeedClasses = document.getElementsByClassName("amplitude-playback-speed"); 4093 4094 /* 4095 Iterates over all of the playback speed classes 4096 applying the right speed class for visual purposes. 4097 */ 4098 for (var i = 0; i < playbackSpeedClasses.length; i++) { 4099 /* 4100 Removes all of the old playback speed classes. 4101 */ 4102 playbackSpeedClasses[i].classList.remove("amplitude-playback-speed-10"); 4103 playbackSpeedClasses[i].classList.remove("amplitude-playback-speed-15"); 4104 playbackSpeedClasses[i].classList.remove("amplitude-playback-speed-20"); 4105 4106 /* 4107 Switch the current playback speed and apply the appropriate 4108 speed class. 4109 */ 4110 switch (_config2.default.playback_speed) { 4111 case 1: 4112 playbackSpeedClasses[i].classList.add("amplitude-playback-speed-10"); 4113 break; 4114 case 1.5: 4115 playbackSpeedClasses[i].classList.add("amplitude-playback-speed-15"); 4116 break; 4117 case 2: 4118 playbackSpeedClasses[i].classList.add("amplitude-playback-speed-20"); 4119 break; 4120 } 4121 } 4122 } 4123 4124 /** 4125 * Returns the public facing methods 4126 */ 4127 return { 4128 sync: sync 4129 }; 4130}(); /** 4131 * Imports the config module 4132 * @module config 4133 */ 4134exports.default = PlaybackSpeedElements; 4135module.exports = exports["default"]; 4136 4137/***/ }), 4138/* 19 */ 4139/***/ (function(module, exports, __webpack_require__) { 4140 4141"use strict"; 4142 4143 4144Object.defineProperty(exports, "__esModule", { 4145 value: true 4146}); 4147 4148var _config = __webpack_require__(0); 4149 4150var _config2 = _interopRequireDefault(_config); 4151 4152function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4153 4154/** 4155 * Handles all of the shuffle elements 4156 * @module visual/ShuffleElements 4157 */ 4158var ShuffleElements = function () { 4159 /** 4160 * Syncs the global shuffle button visual state. 4161 * 4162 * @access public 4163 */ 4164 function syncMain() { 4165 /* 4166 Gets the shuffle buttons. 4167 */ 4168 var shuffleButtons = document.getElementsByClassName("amplitude-shuffle"); 4169 4170 /* 4171 Iterate over all of the shuffle buttons. 4172 */ 4173 for (var i = 0; i < shuffleButtons.length; i++) { 4174 /* 4175 Ensure the shuffle button doesn't belong to a playlist. We have 4176 a separate method for that. 4177 */ 4178 if (shuffleButtons[i].getAttribute("data-amplitude-playlist") == null) { 4179 /* 4180 If the state of the player is shuffled on, true, then 4181 we add the 'amplitude-shuffle-on' class and remove the 4182 'amplitude-shuffle-off' class. If the player is not shuffled 4183 then we do the opposite. 4184 */ 4185 if (_config2.default.shuffle_on) { 4186 shuffleButtons[i].classList.add("amplitude-shuffle-on"); 4187 shuffleButtons[i].classList.remove("amplitude-shuffle-off"); 4188 } else { 4189 shuffleButtons[i].classList.add("amplitude-shuffle-off"); 4190 shuffleButtons[i].classList.remove("amplitude-shuffle-on"); 4191 } 4192 } 4193 } 4194 } 4195 4196 /** 4197 * Syncs the playlist shuffle button visual state. 4198 * 4199 * @access public 4200 * @param {string} playlist - The playlist string the shuffle button belongs to. 4201 */ 4202 function syncPlaylist(playlist) { 4203 /* 4204 Gets all of the shuffle buttons. 4205 */ 4206 var shuffleButtons = document.querySelectorAll('.amplitude-shuffle[data-amplitude-playlist="' + playlist + '"]'); 4207 4208 /* 4209 Iterate over all of the shuffle buttons 4210 */ 4211 for (var i = 0; i < shuffleButtons.length; i++) { 4212 /* 4213 If the state of the playlist is shuffled on, true, then 4214 we add the 'amplitude-shuffle-on' class and remove the 4215 'amplitude-shuffle-off' class. If the player is not shuffled 4216 then we do the opposite. 4217 */ 4218 if (_config2.default.playlists[playlist].shuffle) { 4219 shuffleButtons[i].classList.add("amplitude-shuffle-on"); 4220 shuffleButtons[i].classList.remove("amplitude-shuffle-off"); 4221 } else { 4222 shuffleButtons[i].classList.add("amplitude-shuffle-off"); 4223 shuffleButtons[i].classList.remove("amplitude-shuffle-on"); 4224 } 4225 } 4226 } 4227 4228 /** 4229 * Returns public facing methods 4230 */ 4231 return { 4232 syncMain: syncMain, 4233 syncPlaylist: syncPlaylist 4234 }; 4235}(); /** 4236 * Imports the config module 4237 * @module config 4238 */ 4239exports.default = ShuffleElements; 4240module.exports = exports["default"]; 4241 4242/***/ }), 4243/* 20 */ 4244/***/ (function(module, exports, __webpack_require__) { 4245 4246"use strict"; 4247 4248 4249Object.defineProperty(exports, "__esModule", { 4250 value: true 4251}); 4252 4253var _config = __webpack_require__(0); 4254 4255var _config2 = _interopRequireDefault(_config); 4256 4257function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4258 4259/** 4260 * Handles the syncing of the song played progress elements. 4261 * 4262 * @module visual/SongPlayedProgressElements 4263 */ 4264var SongPlayedProgressElements = function () { 4265 /** 4266 * Syncs the song played progress bars. These are HTML5 progress elements. 4267 * 4268 * @access private 4269 * @param {number} songPlayedPercentage - The percentage of the song that has been played. 4270 */ 4271 function sync(songPlayedPercentage) { 4272 syncGlobal(songPlayedPercentage); 4273 syncPlaylist(songPlayedPercentage); 4274 syncSong(songPlayedPercentage); 4275 syncSongInPlaylist(songPlayedPercentage); 4276 } 4277 4278 /** 4279 * Sync how much has been played with a progress bar. This is the global progress bar. 4280 * 4281 * @access private 4282 * @param {number} songPlayedPercentage - The percent of the song completed. 4283 */ 4284 function syncGlobal(percentage) { 4285 /* 4286 Ensure that the song completion percentage is a number 4287 */ 4288 if (!isNaN(percentage)) { 4289 /* 4290 Get all of the song progress bars 4291 */ 4292 var songPlayedProgressBars = document.querySelectorAll(".amplitude-song-played-progress"); 4293 4294 for (var i = 0; i < songPlayedProgressBars.length; i++) { 4295 var playlist = songPlayedProgressBars[i].getAttribute("data-amplitude-playlist"); 4296 var songIndex = songPlayedProgressBars[i].getAttribute("data-amplitude-song-index"); 4297 4298 if (playlist == null && songIndex == null) { 4299 var max = songPlayedProgressBars[i].max; 4300 4301 songPlayedProgressBars[i].value = percentage / 100 * max; 4302 } 4303 } 4304 } 4305 } 4306 4307 /** 4308 * Sync how much has been played with a progress bar. This is the playlist progress bar. 4309 * 4310 * @access public 4311 * @param {number} songPlayedPercentage - The percent of the song completed. 4312 */ 4313 function syncPlaylist(percentage) { 4314 /* 4315 Ensure that the song completion percentage is a number 4316 */ 4317 if (!isNaN(percentage)) { 4318 /* 4319 Get all of the song progress bars 4320 */ 4321 var songPlayedProgressBars = document.querySelectorAll('.amplitude-song-played-progress[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 4322 4323 for (var i = 0; i < songPlayedProgressBars.length; i++) { 4324 var song = songPlayedProgressBars[i].getAttribute("data-amplitude-song-index"); 4325 4326 if (song == null) { 4327 var max = songPlayedProgressBars[i].max; 4328 4329 songPlayedProgressBars[i].value = percentage / 100 * max; 4330 } 4331 } 4332 } 4333 } 4334 4335 /** 4336 * Sync how much has been played with a progress bar. This is for an individual song. 4337 * 4338 * @access private 4339 * @param {number} songPlayedPercentage - The percent of the song completed. 4340 */ 4341 function syncSong(percentage) { 4342 if (_config2.default.active_playlist == null) { 4343 /* 4344 Ensure that the song completion percentage is a number 4345 */ 4346 if (!isNaN(percentage)) { 4347 /* 4348 Get all of the song progress bars 4349 */ 4350 var songPlayedProgressBars = document.querySelectorAll('.amplitude-song-played-progress[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 4351 4352 for (var i = 0; i < songPlayedProgressBars.length; i++) { 4353 var playlist = songPlayedProgressBars[i].getAttribute("data-amplitude-playlist"); 4354 4355 if (playlist == null) { 4356 var max = songPlayedProgressBars[i].max; 4357 4358 songPlayedProgressBars[i].value = percentage / 100 * max; 4359 } 4360 } 4361 } 4362 } 4363 } 4364 4365 /** 4366 * Sync how much has been played with a progress bar. This is for an individual song in playlist. 4367 * 4368 * @access private 4369 * @param {number} songPlayedPercentage - The percent of the song completed. 4370 */ 4371 function syncSongInPlaylist(percentage) { 4372 /* 4373 Ensure that the song completion percentage is a number 4374 */ 4375 if (!isNaN(percentage)) { 4376 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 4377 4378 /* 4379 Get all of the song progress bars 4380 */ 4381 var songPlayedProgressBars = document.querySelectorAll('.amplitude-song-played-progress[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 4382 4383 /* 4384 Iterates over all of the song played progress elements 4385 and sets them accordingly. 4386 */ 4387 for (var i = 0; i < songPlayedProgressBars.length; i++) { 4388 var playlist = songPlayedProgressBars[i].getAttribute("data-amplitude-playlist"); 4389 var songIndex = songPlayedProgressBars[i].getAttribute("data-amplitude-song-index"); 4390 4391 if (playlist != null && songIndex != null) { 4392 var max = songPlayedProgressBars[i].max; 4393 4394 songPlayedProgressBars[i].value = percentage / 100 * max; 4395 } 4396 } 4397 } 4398 } 4399 4400 /** 4401 * Sets all of the song played progress bars to 0 4402 * 4403 * @access public 4404 */ 4405 function resetElements() { 4406 var songPlayedProgressBars = document.getElementsByClassName("amplitude-song-played-progress"); 4407 4408 for (var i = 0; i < songPlayedProgressBars.length; i++) { 4409 songPlayedProgressBars[i].value = 0; 4410 } 4411 } 4412 4413 return { 4414 sync: sync, 4415 resetElements: resetElements 4416 }; 4417}(); /** 4418 * Imports the config module 4419 * @module config 4420 */ 4421exports.default = SongPlayedProgressElements; 4422module.exports = exports["default"]; 4423 4424/***/ }), 4425/* 21 */ 4426/***/ (function(module, exports, __webpack_require__) { 4427 4428"use strict"; 4429 4430 4431Object.defineProperty(exports, "__esModule", { 4432 value: true 4433}); 4434 4435var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /** 4436 * Imports the config module 4437 * @module config 4438 */ 4439 4440 4441/** 4442 * AmplitudeJS Core Module 4443 * @module core/Core 4444 */ 4445 4446 4447/** 4448 * AmplitudeJS SoundCloud Module 4449 * @module soundcloud/SoundCloud 4450 */ 4451 4452 4453/** 4454 * Imports the utilities used by the main module. 4455 */ 4456/** 4457 * AmplitudeJS Config State Module 4458 * @module utilities/ConfigState 4459 */ 4460 4461 4462/** 4463 * AmplitudeJS Debug Module 4464 * @module utilities/Debug 4465 */ 4466 4467 4468/** 4469 * AmplitudeJS Checks Module 4470 * @module utilities/Checks 4471 */ 4472 4473 4474/** 4475 * AmplitudeJS Shuffler Module 4476 * @module utilities/Shuffler 4477 */ 4478 4479 4480/** 4481 * AmplitudeJS Events Module 4482 * @module events/Events 4483 */ 4484 4485 4486/** 4487 * AmplitudeJS FX Module 4488 * @module fx/Fx 4489 */ 4490 4491 4492/** 4493 * AmplitudeJS Visualizations Module 4494 * @module fx/Visualizations 4495 */ 4496 4497 4498/** 4499 * AmplitudeJS WaveForm Module 4500 * @module fx/WaveForm 4501 */ 4502 4503 4504/** 4505 * AmplitudeJS Audio Navigation Module. 4506 * @module utilities/AudioNavigation 4507 */ 4508 4509 4510/** 4511 * AmplitudeJS Callbacks Module 4512 * @module utilities/Callbacks 4513 */ 4514 4515 4516/** 4517 * AmplitudeJS Playlists Initializer Module 4518 * @module init/Playlists 4519 */ 4520 4521 4522/** 4523 * Imports the AmplitudeJS Shuffle Elements 4524 * @module visual/ShuffleElements 4525 */ 4526 4527 4528/** 4529 * Imports the AmplitudeJS Mute Elements 4530 * @module visual/MuteElements 4531 */ 4532 4533 4534/** 4535 * Imports the AmplitudeJS Volume Slider 4536 * @module visual/VolumeSliderElements 4537 */ 4538 4539 4540/** 4541 * Imports the AmplitudeJS Time Elements 4542 * @module visual/TimeElements 4543 */ 4544 4545 4546/** 4547 * Imports the AmplitudeJS Play/Pause Elements Module. 4548 * @module visual/PlayPauseElements 4549 */ 4550 4551 4552/** 4553 * Imports the AmplitudeJS MetaData Elements Module. 4554 * @module visual/MetaDataElements 4555 */ 4556 4557 4558/** 4559 * Imports the AmplitudeJS PlaybackSpeedElements Module. 4560 * @module visual/PlayBackSpeedElements 4561 */ 4562 4563 4564/** 4565 * Imports the AmplitudeJS Repeat Element 4566 * @module visual/RepeatElements 4567 */ 4568 4569 4570var _config = __webpack_require__(0); 4571 4572var _config2 = _interopRequireDefault(_config); 4573 4574var _core = __webpack_require__(1); 4575 4576var _core2 = _interopRequireDefault(_core); 4577 4578var _soundcloud = __webpack_require__(17); 4579 4580var _soundcloud2 = _interopRequireDefault(_soundcloud); 4581 4582var _configState = __webpack_require__(6); 4583 4584var _configState2 = _interopRequireDefault(_configState); 4585 4586var _debug = __webpack_require__(4); 4587 4588var _debug2 = _interopRequireDefault(_debug); 4589 4590var _checks = __webpack_require__(5); 4591 4592var _checks2 = _interopRequireDefault(_checks); 4593 4594var _shuffler = __webpack_require__(13); 4595 4596var _shuffler2 = _interopRequireDefault(_shuffler); 4597 4598var _events = __webpack_require__(26); 4599 4600var _events2 = _interopRequireDefault(_events); 4601 4602var _fx = __webpack_require__(46); 4603 4604var _fx2 = _interopRequireDefault(_fx); 4605 4606var _visualizations = __webpack_require__(16); 4607 4608var _visualizations2 = _interopRequireDefault(_visualizations); 4609 4610var _waveform = __webpack_require__(22); 4611 4612var _waveform2 = _interopRequireDefault(_waveform); 4613 4614var _audioNavigation = __webpack_require__(3); 4615 4616var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 4617 4618var _callbacks = __webpack_require__(9); 4619 4620var _callbacks2 = _interopRequireDefault(_callbacks); 4621 4622var _playlists = __webpack_require__(48); 4623 4624var _playlists2 = _interopRequireDefault(_playlists); 4625 4626var _shuffleElements = __webpack_require__(19); 4627 4628var _shuffleElements2 = _interopRequireDefault(_shuffleElements); 4629 4630var _muteElements = __webpack_require__(10); 4631 4632var _muteElements2 = _interopRequireDefault(_muteElements); 4633 4634var _volumeSliderElements = __webpack_require__(11); 4635 4636var _volumeSliderElements2 = _interopRequireDefault(_volumeSliderElements); 4637 4638var _timeElements = __webpack_require__(15); 4639 4640var _timeElements2 = _interopRequireDefault(_timeElements); 4641 4642var _playPauseElements = __webpack_require__(2); 4643 4644var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 4645 4646var _metaDataElements = __webpack_require__(7); 4647 4648var _metaDataElements2 = _interopRequireDefault(_metaDataElements); 4649 4650var _playbackSpeedElements = __webpack_require__(18); 4651 4652var _playbackSpeedElements2 = _interopRequireDefault(_playbackSpeedElements); 4653 4654var _repeatElements = __webpack_require__(8); 4655 4656var _repeatElements2 = _interopRequireDefault(_repeatElements); 4657 4658function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4659 4660/** 4661 * AmplitudeJS Initializer Module. Helps with the handling of all of the 4662 * initialization for AmplitudeJS. 4663 * 4664 * @module init/Initializer 4665 */ 4666var Initializer = function () { 4667 /** 4668 * The main init function. The user will call this through 4669 * Amplitude.init({}) and pass in their settings. 4670 * 4671 * Public Accessor: Amplitude.init( user_config_json ) 4672 * @access public 4673 * @param {object} userConfig - A JSON object of user defined values that help configure and initialize AmplitudeJS. 4674 */ 4675 function initialize(userConfig) { 4676 var ready = false; 4677 4678 /* 4679 Reset the config on init so we have a clean slate. This is if the 4680 user has to re-init. 4681 */ 4682 _configState2.default.resetConfig(); 4683 4684 /* 4685 Initialize event handlers on init. This will clear any old 4686 event handlers on the amplitude element and re-bind what is 4687 necessary. 4688 */ 4689 _events2.default.initialize(); 4690 4691 /* 4692 Initialize the callbacks we listen to for the audio object. 4693 */ 4694 _callbacks2.default.initialize(); 4695 4696 /* 4697 Initializes debugging right away so we can use it for the rest 4698 of the configuration. 4699 */ 4700 _config2.default.debug = userConfig.debug != undefined ? userConfig.debug : false; 4701 4702 /* 4703 Set default artwork, if specified. 4704 */ 4705 setArt(userConfig); 4706 4707 /* 4708 Checks to see if the user has songs defined. 4709 */ 4710 if (userConfig.songs) { 4711 /* 4712 Checks to see if the user has some songs in the songs array. 4713 */ 4714 if (userConfig.songs.length != 0) { 4715 /* 4716 Copies over the user defined songs. and prepares 4717 Amplitude for the rest of the configuration. 4718 */ 4719 _config2.default.songs = userConfig.songs; 4720 /* 4721 Flag amplitude as ready. 4722 */ 4723 ready = true; 4724 } else { 4725 _debug2.default.writeMessage("Please add some songs, to your songs object!"); 4726 } 4727 } else { 4728 _debug2.default.writeMessage("Please provide a songs object for AmplitudeJS to run!"); 4729 } 4730 4731 /* 4732 Initializes the audio context. In this method it checks to see if the 4733 user wants to use visualizations or not before proceeding. 4734 */ 4735 if (_fx2.default.webAudioAPIAvailable()) { 4736 if (_fx2.default.determineUsingAnyFX()) { 4737 /* 4738 Configure the Web Audio API If It's available. 4739 */ 4740 _fx2.default.configureWebAudioAPI(); 4741 4742 /* 4743 Activates the audio context after an event for the user. 4744 */ 4745 document.documentElement.addEventListener("mousedown", function () { 4746 if (_config2.default.context.state !== "running") { 4747 _config2.default.context.resume(); 4748 } 4749 }); 4750 4751 document.documentElement.addEventListener("keydown", function () { 4752 if (_config2.default.context.state !== "running") { 4753 _config2.default.context.resume(); 4754 } 4755 }); 4756 4757 document.documentElement.addEventListener("keyup", function () { 4758 if (_config2.default.context.state !== "running") { 4759 _config2.default.context.resume(); 4760 } 4761 }); 4762 4763 /* 4764 Set the user waveform settings if provided. 4765 */ 4766 if (userConfig.waveforms != undefined && userConfig.waveforms.sample_rate != undefined) { 4767 _config2.default.waveforms.sample_rate = userConfig.waveforms.sample_rate; 4768 } 4769 4770 /* 4771 Initialize the waveform. 4772 */ 4773 _waveform2.default.init(); 4774 4775 /* 4776 If the user is registering visualizations on init, 4777 we set them right away. 4778 */ 4779 if (userConfig.visualizations != undefined && userConfig.visualizations.length > 0) { 4780 /* 4781 Iterate over all of the visualizations and 4782 register them in our player. 4783 */ 4784 for (var i = 0; i < userConfig.visualizations.length; i++) { 4785 _visualizations2.default.register(userConfig.visualizations[i].object, userConfig.visualizations[i].params); 4786 } 4787 } 4788 } 4789 } else { 4790 _debug2.default.writeMessage("The Web Audio API is not available on this platform. We are using your defined backups!"); 4791 } 4792 4793 /* 4794 Initialize default live settings 4795 */ 4796 initializeDefaultLiveSettings(); 4797 4798 /* 4799 Initialize default song indexes 4800 */ 4801 initializeDefaultSongIndexes(); 4802 4803 /* 4804 When the preliminary config is ready, we are ready to proceed. 4805 */ 4806 if (ready) { 4807 /* 4808 Copies over the soundcloud information to the global config 4809 which will determine where we go from there. 4810 */ 4811 _config2.default.soundcloud_client = userConfig.soundcloud_client != undefined ? userConfig.soundcloud_client : ""; 4812 4813 /* 4814 Checks if we want to use the art loaded from soundcloud. 4815 */ 4816 _config2.default.soundcloud_use_art = userConfig.soundcloud_use_art != undefined ? userConfig.soundcloud_use_art : ""; 4817 4818 /* 4819 If the user provides a soundcloud client then we assume that 4820 there are URLs in their songs that will reference SoundCloud. 4821 We then copy over the user config they provided to the 4822 temp_user_config so we don't mess up the global or their configs 4823 and load the soundcloud information. 4824 */ 4825 var tempUserConfig = {}; 4826 4827 /* 4828 If there's a soundcloud_client key set, we load the SoundCloud data 4829 for all of the songs in the array. 4830 */ 4831 if (_config2.default.soundcloud_client != "") { 4832 tempUserConfig = userConfig; 4833 4834 /* 4835 Load up SoundCloud for use with AmplitudeJS. 4836 */ 4837 _soundcloud2.default.loadSoundCloud(tempUserConfig); 4838 } else { 4839 /* 4840 The user is not using Soundcloud with Amplitude at this point 4841 so we just finish the configuration with the users's preferences. 4842 */ 4843 setConfig(userConfig); 4844 } 4845 } 4846 4847 /* 4848 Debug out what was initialized with AmplitudeJS. 4849 */ 4850 _debug2.default.writeMessage("Initialized With: "); 4851 _debug2.default.writeMessage(_config2.default); 4852 } 4853 4854 /** 4855 * Rebinds all of the elements in the display. 4856 * 4857 * Public Accessor: Amplitude.rebindDisplay() 4858 * @access public 4859 */ 4860 function rebindDisplay() { 4861 _events2.default.initialize(); 4862 _metaDataElements2.default.displayMetaData(); 4863 } 4864 4865 /** 4866 * Finishes the initalization of the config. Takes all of the user defined 4867 * parameters and makes sure they override the defaults. The important 4868 * config information is assigned in the publicInit() function. 4869 * 4870 * This function can be called from 2 different locations: 4871 * 1. Right away on init after the important settings are defined. 4872 * 4873 * 2. After all of the Soundcloud URLs are resolved properly and 4874 * soundcloud is configured. We will need the proper URLs from Soundcloud 4875 * to stream through Amplitude so we get those right away before we 4876 * set the information and the active song 4877 * 4878 * @access public 4879 * @param {object} userConfig - A JSON object of user defined values that help configure and initialize AmplitudeJS. 4880 */ 4881 function setConfig(userConfig) { 4882 /* 4883 Checks if the user has any playlists defined. If they do 4884 we have to initialize the functionality for the playlists. 4885 */ 4886 if (userConfig.playlists && countPlaylists(userConfig.playlists) > 0) { 4887 _playlists2.default.initialize(userConfig.playlists); 4888 } 4889 4890 /* 4891 Check to see if the user entered a start song 4892 */ 4893 if (userConfig.start_song != undefined && !userConfig.starting_playlist) { 4894 /* 4895 Ensure what has been entered is an integer. 4896 */ 4897 if (_checks2.default.isInt(userConfig.start_song)) { 4898 _audioNavigation2.default.changeSong(_config2.default.songs[userConfig.start_song], userConfig.start_song); 4899 } else { 4900 _debug2.default.writeMessage("You must enter an integer index for the start song."); 4901 } 4902 } else { 4903 _audioNavigation2.default.changeSong(_config2.default.songs[0], 0); 4904 } 4905 4906 /* 4907 If the shuffle is on by default, shuffle the songs and 4908 switch to the shuffled song. 4909 */ 4910 if (userConfig.shuffle_on != undefined && userConfig.shuffle_on) { 4911 _config2.default.shuffle_on = true; 4912 _shuffler2.default.shuffleSongs(); 4913 4914 _audioNavigation2.default.changeSong(_config2.default.shuffle_list[0], 0); 4915 } 4916 4917 /* 4918 Allows the user to set whether they want to continue to the next song 4919 when the current song finishes or not. In any scenario that's not a playlist, 4920 contining to the next song may not be desired. 4921 */ 4922 _config2.default.continue_next = userConfig.continue_next != undefined ? userConfig.continue_next : true; 4923 4924 /* 4925 If the user defined a playback speed, we copy over their 4926 preference here, otherwise we default to normal playback 4927 speed of 1.0. 4928 */ 4929 _config2.default.playback_speed = userConfig.playback_speed != undefined ? userConfig.playback_speed : 1.0; 4930 4931 /* 4932 Sets the audio playback speed. 4933 */ 4934 _core2.default.setPlaybackSpeed(_config2.default.playback_speed); 4935 4936 /* 4937 If the user wants the song to be pre-loaded for instant 4938 playback, they set it to true. By default it's set to just 4939 load the metadata. 4940 */ 4941 _config2.default.audio.preload = userConfig.preload != undefined ? userConfig.preload : "auto"; 4942 4943 /* 4944 Initializes the user defined callbacks. This should be a JSON 4945 object that contains a key->value store of the callback name 4946 and the name of the function the user needs to call. 4947 */ 4948 _config2.default.callbacks = userConfig.callbacks != undefined ? userConfig.callbacks : {}; 4949 4950 /* 4951 Initializes the user defined key bindings. This should be a JSON 4952 object that contains a key->value store of the key event number 4953 pressed and the method to be run. 4954 */ 4955 _config2.default.bindings = userConfig.bindings != undefined ? userConfig.bindings : {}; 4956 4957 /* 4958 The user can define a starting volume in a range of 0-100 with 4959 0 being muted and 100 being the loudest. After the config is set 4960 Amplitude sets the active song's volume to the volume defined 4961 by the user. 4962 */ 4963 _config2.default.volume = userConfig.volume != undefined ? userConfig.volume : 50; 4964 4965 /* 4966 Sets the delay between songs if the user has it set. This should be in MS. 4967 */ 4968 _config2.default.delay = userConfig.delay != undefined ? userConfig.delay : 0; 4969 4970 /* 4971 The user can set the volume increment and decrement values between 1 and 100 4972 for when the volume up or down button is pressed. The default is an increase 4973 or decrease of 5. 4974 */ 4975 _config2.default.volume_increment = userConfig.volume_increment != undefined ? userConfig.volume_increment : 5; 4976 4977 _config2.default.volume_decrement = userConfig.volume_decrement != undefined ? userConfig.volume_decrement : 5; 4978 4979 /* 4980 Set the volume to what is defined in the config. The user can define this, 4981 so we should set it up that way. 4982 */ 4983 _core2.default.setVolume(_config2.default.volume); 4984 4985 /* 4986 Set default artwork, if specified 4987 */ 4988 setArt(userConfig); 4989 4990 /* 4991 Initialize the visual elements 4992 */ 4993 initializeElements(); 4994 4995 /* 4996 If the user has selected a starting playlist, we need to set the starting playlist 4997 and sync the visuals 4998 */ 4999 if (userConfig.starting_playlist != undefined && userConfig.starting_playlist != "") { 5000 /* 5001 Set the active playlist to the starting playlist by the user 5002 */ 5003 _config2.default.active_playlist = userConfig.starting_playlist; 5004 5005 /* 5006 Check if the user defined a song to start with in the playlist. 5007 */ 5008 if (userConfig.starting_playlist_song != undefined && userConfig.starting_playlist_song != "") { 5009 /* 5010 Ensure the song is a valid index. 5011 */ 5012 if (_typeof(userConfig.playlists[userConfig.starting_playlist].songs[parseInt(userConfig.starting_playlist_song)]) != undefined) { 5013 /* 5014 Set the player to the song defined by the user. 5015 */ 5016 _audioNavigation2.default.changeSongPlaylist(_config2.default.active_playlist, userConfig.playlists[userConfig.starting_playlist].songs[parseInt(userConfig.starting_playlist_song)], parseInt(userConfig.starting_playlist_song)); 5017 } else { 5018 /* 5019 Set the player to the first song in the playlist 5020 */ 5021 _audioNavigation2.default.changeSongPlaylist(_config2.default.active_playlist, userConfig.playlists[userConfig.starting_playlist].songs[0], 0); 5022 /* 5023 Debug that the song index doesn't exist 5024 */ 5025 _debug2.default.writeMessage("The index of " + userConfig.starting_playlist_song + " does not exist in the playlist " + userConfig.starting_playlist); 5026 } 5027 } else { 5028 /* 5029 Set the player to the first song in the playlist 5030 */ 5031 _audioNavigation2.default.changeSong(_config2.default.active_playlist, userConfig.playlists[userConfig.starting_playlist].songs[0], 0); 5032 } 5033 5034 /* 5035 Sync the main and song play pause buttons. 5036 */ 5037 _playPauseElements2.default.sync(); 5038 } 5039 5040 /* 5041 Run after init callback 5042 */ 5043 _callbacks2.default.run("initialized"); 5044 } 5045 5046 /** 5047 * Sets the default_album_art and default_playlist_art from the 5048 * user supplied configuration. 5049 * 5050 * @access public 5051 * @param {object} userConfig - A JSON object of user defined values that help configure and initialize AmplitudeJS. 5052 */ 5053 function setArt(userConfig) { 5054 /* 5055 If the user defines default album art, this image will display if the active 5056 song doesn't have album art defined. 5057 */ 5058 if (userConfig.default_album_art != undefined) { 5059 _config2.default.default_album_art = userConfig.default_album_art; 5060 } else { 5061 _config2.default.default_album_art = ""; 5062 } 5063 5064 /* 5065 If the user defines default playlist art, this image will display if the user 5066 tries to set up a playlist meta data image tag but doesn't have one defined. 5067 */ 5068 if (userConfig.default_playlist_art != undefined) { 5069 _config2.default.default_playlist_art = userConfig.default_playlist_art; 5070 } else { 5071 _config2.default.default_playlist_art = ""; 5072 } 5073 } 5074 5075 /** 5076 * Initializes all of the elements on the page to the default starting point 5077 * to build from there. 5078 * 5079 * @access private 5080 */ 5081 function initializeElements() { 5082 /* 5083 Visually sync the shuffle statuses 5084 */ 5085 _shuffleElements2.default.syncMain(); 5086 5087 /* 5088 Sync Mute Elements. 5089 */ 5090 _muteElements2.default.setMuted(_config2.default.volume == 0 ? true : false); 5091 5092 /* 5093 Sync Volume Slider Elements 5094 */ 5095 _volumeSliderElements2.default.sync(); 5096 5097 /* 5098 Syncs all of the playback speed elements. 5099 */ 5100 _playbackSpeedElements2.default.sync(); 5101 5102 /* 5103 Syncs all of the visual time elements to 00. 5104 */ 5105 _timeElements2.default.resetCurrentTimes(); 5106 5107 /* 5108 Sets all of the play pause buttons to pause. 5109 */ 5110 _playPauseElements2.default.syncToPause(); 5111 5112 /* 5113 Sets the meta data for the songs automatically. 5114 */ 5115 _metaDataElements2.default.syncMetaData(); 5116 5117 /* 5118 Sets the repeat buttons automatically. 5119 */ 5120 _repeatElements2.default.syncRepeatSong(); 5121 } 5122 5123 /** 5124 * Counts the number of playlists the user has configured. This ensures 5125 * that the user has at least 1 playlist so we can validate the songs 5126 * defined in the playlist are correct and they didn't enter an invalid 5127 * ID. 5128 * 5129 * @access private 5130 * @param {object} playlists - 5131 */ 5132 function countPlaylists(playlists) { 5133 /* 5134 Initialize the placeholders to iterate through the playlists 5135 and find out how many we have to account for. 5136 */ 5137 var size = 0, 5138 key = void 0; 5139 5140 /* 5141 Iterate over playlists and if the user has the playlist defined, 5142 increment the size of playlists. 5143 */ 5144 for (key in playlists) { 5145 if (playlists.hasOwnProperty(key)) { 5146 size++; 5147 } 5148 } 5149 5150 /* 5151 Debug how many playlists are in the config. 5152 */ 5153 _debug2.default.writeMessage("You have " + size + " playlist(s) in your config"); 5154 5155 /* 5156 Return the number of playlists in the config. 5157 */ 5158 return size; 5159 } 5160 5161 /** 5162 * Intializes the default live settings for all of the songs. 5163 * 5164 * @access private 5165 */ 5166 function initializeDefaultLiveSettings() { 5167 for (var i = 0; i < _config2.default.songs.length; i++) { 5168 if (_config2.default.songs[i].live == undefined) { 5169 _config2.default.songs[i].live = false; 5170 } 5171 } 5172 } 5173 5174 /** 5175 * Initializes the index of the song in the songs array so 5176 * we can reference it if needed 5177 * 5178 * @access private 5179 */ 5180 function initializeDefaultSongIndexes() { 5181 for (var i = 0; i < _config2.default.songs.length; i++) { 5182 _config2.default.songs[i].index = i; 5183 } 5184 } 5185 5186 /* 5187 Returns the publicly accessible methods 5188 */ 5189 return { 5190 initialize: initialize, 5191 setConfig: setConfig, 5192 rebindDisplay: rebindDisplay 5193 }; 5194}(); 5195 5196exports.default = Initializer; 5197module.exports = exports["default"]; 5198 5199/***/ }), 5200/* 22 */ 5201/***/ (function(module, exports, __webpack_require__) { 5202 5203"use strict"; 5204 5205 5206Object.defineProperty(exports, "__esModule", { 5207 value: true 5208}); 5209 5210var _config = __webpack_require__(0); 5211 5212var _config2 = _interopRequireDefault(_config); 5213 5214function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5215 5216/** 5217 * Builds a waveform for the current audio. 5218 * Help from: https://robots.thoughtbot.com/javascript-audio-api 5219 * https://stackoverflow.com/questions/21347833/html-svg-not-drawing-works-in-other-pages 5220 */ 5221var WaveForm = function () { 5222 /* 5223 Initialize the local variables used in the Waveform. 5224 */ 5225 var buffer = ""; 5226 var sampleRate = ""; 5227 var peaks = ""; 5228 5229 function init() { 5230 sampleRate = _config2.default.waveforms.sample_rate; 5231 5232 /* 5233 Grabs all of the waveform elements on the page. 5234 */ 5235 var waveforms = document.querySelectorAll(".amplitude-wave-form"); 5236 5237 /* 5238 If there are waveforms, we iterate over them and set them up to display 5239 properly. 5240 */ 5241 if (waveforms.length > 0) { 5242 /* 5243 Iterate over all of the waveforms and build the SVG parts. 5244 */ 5245 for (var i = 0; i < waveforms.length; i++) { 5246 /* 5247 Clear the inner HTML of the element if we are replacing the waveform. 5248 */ 5249 waveforms[i].innerHTML = ""; 5250 5251 /* 5252 Inserts an SVG into the element. 5253 */ 5254 var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); 5255 svg.setAttribute("viewBox", "0 -1 " + sampleRate + " 2"); 5256 svg.setAttribute("preserveAspectRatio", "none"); 5257 5258 /* 5259 Add a g component to the SVG 5260 */ 5261 var g = document.createElementNS("http://www.w3.org/2000/svg", "g"); 5262 svg.appendChild(g); 5263 5264 /* 5265 Add a path component to the g 5266 */ 5267 var path = document.createElementNS("http://www.w3.org/2000/svg", "path"); 5268 path.setAttribute("d", ""); 5269 path.setAttribute("id", "waveform"); 5270 5271 g.appendChild(path); 5272 5273 /* 5274 Append the SVG to the waveform. 5275 */ 5276 waveforms[i].appendChild(svg); 5277 } 5278 } 5279 } 5280 5281 /** 5282 * Builds each waveform for the page. 5283 */ 5284 function build() { 5285 if (_config2.default.web_audio_api_available) { 5286 /* 5287 If we don't have the wave form built, we need to build the waveform by loading 5288 the src with an array buffer. 5289 */ 5290 if (_config2.default.waveforms.built[Math.abs(_config2.default.audio.src.split("").reduce(function (a, b) { 5291 a = (a << 5) - a + b.charCodeAt(0); 5292 return a & a; 5293 }, 0))] == undefined) { 5294 /* 5295 Initializes a new XML Http Request. 5296 */ 5297 var req = new XMLHttpRequest(); 5298 5299 /* 5300 Opens the src parameter for the audio file to read in. 5301 */ 5302 req.open("GET", _config2.default.audio.src, true); 5303 req.responseType = "arraybuffer"; 5304 5305 /* 5306 When the ready state changes, check to see if we can render the 5307 wave form. 5308 */ 5309 req.onreadystatechange = function (e) { 5310 /* 5311 When the request is complete, then we begin decoding the 5312 audio to build the waveform. 5313 */ 5314 if (req.readyState == 4) { 5315 /* 5316 If the status is 200 means the response is a success and 5317 we decode the audio data. 5318 */ 5319 if (req.status == 200) { 5320 /* 5321 Decode the audio data and process the waveform. 5322 */ 5323 _config2.default.context.decodeAudioData(req.response, function (bufferedAudio) { 5324 /* 5325 Set the buffer to the audio returned. 5326 */ 5327 buffer = bufferedAudio; 5328 5329 /* 5330 Get the peaks in the audio. 5331 */ 5332 peaks = getPeaks(sampleRate, buffer); 5333 5334 /* 5335 Build the SVG 5336 */ 5337 process(sampleRate, buffer, peaks); 5338 }); 5339 } 5340 } 5341 }; 5342 req.send(); 5343 } else { 5344 /* 5345 If we already have a waveform, we grab the waveform that 5346 was created for the song and display it. We do a simple hash 5347 of the song URL so it's already unique. 5348 */ 5349 displayWaveForms(_config2.default.waveforms.built[Math.abs(_config2.default.audio.src.split("").reduce(function (a, b) { 5350 a = (a << 5) - a + b.charCodeAt(0); 5351 return a & a; 5352 }, 0))]); 5353 } 5354 } 5355 } 5356 5357 /** 5358 * Processes the audio and generates the waveform. 5359 * 5360 * @param {sampleRate} sampleRate - The rate we should sample the audio. 5361 * @param {arraybuffer} buffer - The Web Audio API 5362 * @param {array} peaks - The peaks in the audio. 5363 */ 5364 function process(sampleRate, buffer, peaks) { 5365 /* 5366 If we have a buffer, we find the peaks in the audio. 5367 */ 5368 if (buffer) { 5369 /* 5370 Get the total peaks in the song. 5371 */ 5372 var totalPeaks = peaks.length; 5373 5374 /* 5375 Figure out the depth of the peak. 5376 */ 5377 var d = ""; 5378 for (var peakNumber = 0; peakNumber < totalPeaks; peakNumber++) { 5379 if (peakNumber % 2 === 0) { 5380 d += " M" + ~~(peakNumber / 2) + ", " + peaks.shift(); 5381 } else { 5382 d += " L" + ~~(peakNumber / 2) + ", " + peaks.shift(); 5383 } 5384 } 5385 5386 /* 5387 Add the waveform to the built waveforms array. 5388 */ 5389 _config2.default.waveforms.built[Math.abs(_config2.default.audio.src.split("").reduce(function (a, b) { 5390 a = (a << 5) - a + b.charCodeAt(0); 5391 return a & a; 5392 }, 0))] = d; 5393 5394 /* 5395 Display the waveform. 5396 */ 5397 displayWaveForms(_config2.default.waveforms.built[Math.abs(_config2.default.audio.src.split("").reduce(function (a, b) { 5398 a = (a << 5) - a + b.charCodeAt(0); 5399 return a & a; 5400 }, 0))]); 5401 } 5402 } 5403 5404 /** 5405 * Get the peaks of the audio for the waveform. 5406 * 5407 * @param {number} length - The sample size of the audio. 5408 * @param {array} buffer - The array buffer used to find the peaks in the audio. 5409 */ 5410 function getPeaks(length, buffer) { 5411 /* 5412 Set the parameters needed to build the SVG. 5413 */ 5414 var sampleSize = buffer.length / length; 5415 var sampleStep = ~~(sampleSize / 10) || 1; 5416 var numberOfChannels = buffer.numberOfChannels; 5417 var mergedPeaks = []; 5418 5419 /* 5420 Iterate over the channels and find the peaks. 5421 */ 5422 for (var channelNumber = 0; channelNumber < numberOfChannels; channelNumber++) { 5423 /* 5424 Initialize the peaks array and set the channel data to what 5425 the buffer has in its channel data. 5426 */ 5427 var _peaks = []; 5428 var channelData = buffer.getChannelData(channelNumber); 5429 5430 /* 5431 Iterate over peaks with respect to the sample size. 5432 */ 5433 for (var peakNumber = 0; peakNumber < length; peakNumber++) { 5434 /* 5435 Gt the start and end peak. 5436 */ 5437 var start = ~~(peakNumber * sampleSize); 5438 var end = ~~(start + sampleSize); 5439 5440 /* 5441 Set min and max to the channel data first peak. 5442 */ 5443 var min = channelData[0]; 5444 var max = channelData[0]; 5445 5446 /* 5447 Iterate over the parts of the song starting to the 5448 ending to display the waveform. 5449 */ 5450 for (var sampleIndex = start; sampleIndex < end; sampleIndex += sampleStep) { 5451 var value = channelData[sampleIndex]; 5452 5453 if (value > max) { 5454 max = value; 5455 } 5456 if (value < min) { 5457 min = value; 5458 } 5459 } 5460 5461 /* 5462 Set the max and min for the peak. 5463 */ 5464 _peaks[2 * peakNumber] = max; 5465 _peaks[2 * peakNumber + 1] = min; 5466 5467 /* 5468 Merge the peaks 5469 */ 5470 if (channelNumber === 0 || max > mergedPeaks[2 * peakNumber]) { 5471 mergedPeaks[2 * peakNumber] = max; 5472 } 5473 5474 if (channelNumber === 0 || min < mergedPeaks[2 * peakNumber + 1]) { 5475 mergedPeaks[2 * peakNumber + 1] = min; 5476 } 5477 } 5478 } 5479 5480 /* 5481 Returns the merged peaks. 5482 */ 5483 return mergedPeaks; 5484 } 5485 5486 /** 5487 * Displays all of the waveforms necessary. 5488 * 5489 * @param {path} svg - The drawing of the waveform. 5490 */ 5491 function displayWaveForms(svg) { 5492 var waveformElements = document.querySelectorAll(".amplitude-wave-form"); 5493 5494 /* 5495 Iterate over all of the waveform elements and 5496 display the waveform. 5497 */ 5498 for (var i = 0; i < waveformElements.length; i++) { 5499 /* 5500 Get the playlist attribute of the waveform element. 5501 */ 5502 var playlist = waveformElements[i].getAttribute("data-amplitude-playlist"); 5503 5504 /* 5505 Get the song index attribute of the waveform element. 5506 */ 5507 var song = waveformElements[i].getAttribute("data-amplitude-song-index"); 5508 5509 /* 5510 If the playlist is null and the song is null it's a global element. 5511 */ 5512 if (playlist == null && song == null) { 5513 displayGlobalWaveform(waveformElements[i], svg); 5514 } 5515 5516 /* 5517 If the playlist is defined but the song is null it's a playlist element. 5518 */ 5519 if (playlist != null && song == null) { 5520 displayPlaylistWaveform(waveformElements[i], svg, playlist); 5521 } 5522 5523 /* 5524 If the playlist is not defined and the song is not null it's a song 5525 element. 5526 */ 5527 if (playlist == null && song != null) { 5528 displaySongWaveform(waveformElements[i], svg, song); 5529 } 5530 5531 /* 5532 If the playlist and song are defined it's a song in the playlist element. 5533 */ 5534 if (playlist != null && song != null) { 5535 displaySongInPlaylistWaveform(waveformElements[i], svg, playlist, song); 5536 } 5537 } 5538 } 5539 5540 /** 5541 * Displays a global wave form. 5542 * 5543 * @param {Node} element - Element to display the waveform in. 5544 * @param {SVG} svg - The waveform path. 5545 */ 5546 function displayGlobalWaveform(element, svg) { 5547 var waveformPath = element.querySelector("svg g path"); 5548 5549 waveformPath.setAttribute("d", svg); 5550 } 5551 5552 /** 5553 * Displays a playlist wave form. 5554 * 5555 * @param {Node} element - Element to display the waveform in. 5556 * @param {SVG} svg - The waveform path. 5557 * @param {string} playlist - The playlist we are displaying the waveform for. 5558 */ 5559 function displayPlaylistWaveform(element, svg, playlist) { 5560 /* 5561 Ensure the playlist is the active playlist. 5562 */ 5563 if (_config2.default.active_playlist == playlist) { 5564 var waveformPath = element.querySelector("svg g path"); 5565 5566 waveformPath.setAttribute("d", svg); 5567 } 5568 } 5569 5570 /** 5571 * Displays a song wave form. 5572 * 5573 * @param {Node} element - Element to display the waveform in. 5574 * @param {SVG} svg - The waveform path. 5575 * @param {Integer} song - The index of the song we are displaying the 5576 * waveform for. 5577 */ 5578 function displaySongWaveform(element, svg, song) { 5579 /* 5580 Ensure it's the active song being displayed. 5581 */ 5582 if (_config2.default.active_index == song) { 5583 var waveformPath = element.querySelector("svg g path"); 5584 5585 waveformPath.setAttribute("d", svg); 5586 } 5587 } 5588 5589 /** 5590 * Displays a song in playlist waveform. 5591 * 5592 * @param {Node} element - Element to display the waveform in. 5593 * @param {SVG} svg - The waveform path. 5594 * @param {String} playlist - The playlist the waveform is in. 5595 * @param {Integer} song - The index of the song we are displaying the waveform for. 5596 */ 5597 function displaySongInPlaylistWaveform(element, svg, playlist, song) { 5598 /* 5599 Ensure it's the active song in the active playlist. 5600 */ 5601 if (_config2.default.active_playlist == playlist && _config2.default.playlists[_config2.default.active_playlist].active_index == song) { 5602 var waveformPath = element.querySelector("svg g path"); 5603 5604 waveformPath.setAttribute("d", svg); 5605 } 5606 } 5607 5608 /** 5609 * Determines if the user is using waveforms 5610 */ 5611 function determineIfUsingWaveforms() { 5612 var waveforms = document.querySelectorAll(".amplitude-wave-form"); 5613 5614 if (waveforms.length > 0) { 5615 return true; 5616 } else { 5617 return false; 5618 } 5619 } 5620 5621 /* 5622 Return the public methods. 5623 */ 5624 return { 5625 init: init, 5626 build: build, 5627 determineIfUsingWaveforms: determineIfUsingWaveforms 5628 }; 5629}(); /** 5630 * Imports the config module 5631 * @module config 5632 */ 5633exports.default = WaveForm; 5634module.exports = exports["default"]; 5635 5636/***/ }), 5637/* 23 */ 5638/***/ (function(module, exports, __webpack_require__) { 5639 5640"use strict"; 5641 5642 5643Object.defineProperty(exports, "__esModule", { 5644 value: true 5645}); 5646 5647var _config = __webpack_require__(0); 5648 5649var _config2 = _interopRequireDefault(_config); 5650 5651function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5652 5653/** 5654 * The utility to handle the computation of time in AmplitudeJS. 5655 * @module utilities/Time 5656 */ 5657var Time = function () { 5658 /** 5659 * Computes the current song time. Breaks down where the song is into 5660 * hours, minutes, seconds and formats it to be displayed to the user. 5661 * 5662 * @access public 5663 */ 5664 function computeCurrentTimes() { 5665 /* 5666 Initialize the current time object that will be returned. 5667 */ 5668 var currentTime = {}; 5669 5670 /* 5671 Computes the current seconds for the song. 5672 */ 5673 var currentSeconds = (Math.floor(_config2.default.audio.currentTime % 60) < 10 ? "0" : "") + Math.floor(_config2.default.audio.currentTime % 60); 5674 5675 /* 5676 Computes the current minutes for the song. 5677 */ 5678 var currentMinutes = Math.floor(_config2.default.audio.currentTime / 60); 5679 5680 /* 5681 Initialize the current hours variable. 5682 */ 5683 var currentHours = "00"; 5684 5685 /* 5686 If the current minutes is less than 10, we add a leading 0. 5687 */ 5688 if (currentMinutes < 10) { 5689 currentMinutes = "0" + currentMinutes; 5690 } 5691 5692 /* 5693 If the user is more than 60 minutes into the song, then 5694 we extract the hours. 5695 */ 5696 if (currentMinutes >= 60) { 5697 currentHours = Math.floor(currentMinutes / 60); 5698 currentMinutes = currentMinutes % 60; 5699 5700 /* 5701 If the user is less than 10 minutes in, we append the 5702 additional 0 to the minutes. 5703 */ 5704 if (currentMinutes < 10) { 5705 currentMinutes = "0" + currentMinutes; 5706 } 5707 } 5708 5709 /* 5710 Build a clean current time object and send back the appropriate information. 5711 */ 5712 currentTime.seconds = currentSeconds; 5713 currentTime.minutes = currentMinutes; 5714 currentTime.hours = currentHours; 5715 5716 return currentTime; 5717 } 5718 5719 /** 5720 * Computes the current song duration. Breaks down where the song is into 5721 * hours, minutes, seconds and formats it to be displayed to the user. 5722 * 5723 * @access public 5724 */ 5725 function computeSongDuration() { 5726 /* 5727 Initialize the song duration object that will be returned. 5728 */ 5729 var songDuration = {}; 5730 5731 /* 5732 Computes the duration of the song's seconds. 5733 */ 5734 var songDurationSeconds = (Math.floor(_config2.default.audio.duration % 60) < 10 ? "0" : "") + Math.floor(_config2.default.audio.duration % 60); 5735 5736 /* 5737 Computes the duration of the song's minutes. 5738 */ 5739 var songDurationMinutes = Math.floor(_config2.default.audio.duration / 60); 5740 5741 /* 5742 Initialize the hours duration variable. 5743 */ 5744 var songDurationHours = "00"; 5745 5746 /* 5747 If the song duration minutes is less than 10, we add a leading 0. 5748 */ 5749 if (songDurationMinutes < 10) { 5750 songDurationMinutes = "0" + songDurationMinutes; 5751 } 5752 5753 /* 5754 If there is more than 60 minutes in the song, then we 5755 extract the hours. 5756 */ 5757 if (songDurationMinutes >= 60) { 5758 songDurationHours = Math.floor(songDurationMinutes / 60); 5759 songDurationMinutes = songDurationMinutes % 60; 5760 5761 /* 5762 If the song duration minutes is less than 10 we append 5763 the additional 0. 5764 */ 5765 if (songDurationMinutes < 10) { 5766 songDurationMinutes = "0" + songDurationMinutes; 5767 } 5768 } 5769 5770 /* 5771 Build a clean song duration object and send back the appropriate information. 5772 */ 5773 songDuration.seconds = isNaN(songDurationSeconds) ? "00" : songDurationSeconds; 5774 songDuration.minutes = isNaN(songDurationMinutes) ? "00" : songDurationMinutes; 5775 songDuration.hours = isNaN(songDurationHours) ? "00" : songDurationHours.toString(); 5776 5777 return songDuration; 5778 } 5779 5780 /** 5781 * Computes the song completion percentage. 5782 * 5783 * @access public 5784 */ 5785 function computeSongCompletionPercentage() { 5786 return _config2.default.audio.currentTime / _config2.default.audio.duration * 100; 5787 } 5788 5789 /** 5790 * Sets the current time for the audio. 5791 * 5792 * @access public 5793 */ 5794 function setCurrentTime(time) { 5795 /* 5796 If the song is not live, we can set the current time. 5797 */ 5798 if (!_config2.default.active_metadata.live) { 5799 /* 5800 Makes sure the number is finite to set the time. 5801 */ 5802 if (isFinite(time)) { 5803 _config2.default.audio.currentTime = time; 5804 } 5805 } 5806 } 5807 5808 /** 5809 * Defines what is returned by the module 5810 */ 5811 return { 5812 computeCurrentTimes: computeCurrentTimes, 5813 computeSongDuration: computeSongDuration, 5814 computeSongCompletionPercentage: computeSongCompletionPercentage, 5815 setCurrentTime: setCurrentTime 5816 }; 5817}(); /** 5818 * Imports the config module 5819 * @module config 5820 */ 5821exports.default = Time; 5822module.exports = exports["default"]; 5823 5824/***/ }), 5825/* 24 */ 5826/***/ (function(module, exports, __webpack_require__) { 5827 5828"use strict"; 5829 5830 5831Object.defineProperty(exports, "__esModule", { 5832 value: true 5833}); 5834 5835var _config = __webpack_require__(0); 5836 5837var _config2 = _interopRequireDefault(_config); 5838 5839function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5840 5841/** 5842 * AmplitudeJS Visual Handler for Buffered Progress Elements 5843 * 5844 * @module visual/BufferedProgressElements 5845 */ 5846var BufferedProgressElements = function () { 5847 /** 5848 * Syncs the buffered progress bars to the current percentage in the config 5849 * 5850 * @access public 5851 */ 5852 function sync() { 5853 syncGlobal(); 5854 syncPlaylist(); 5855 syncSong(); 5856 syncSongInPlaylist(); 5857 } 5858 5859 /** 5860 * Sync the global song buffered progress elements. 5861 */ 5862 function syncGlobal() { 5863 /* 5864 Gets all of the song buffered progress bars. 5865 */ 5866 var songBufferedProgressBars = document.getElementsByClassName("amplitude-buffered-progress"); 5867 5868 /* 5869 Iterate over all of the song buffered progress bar and 5870 set them to 0 which is like re-setting them. 5871 */ 5872 for (var i = 0; i < songBufferedProgressBars.length; i++) { 5873 var playlist = songBufferedProgressBars[i].getAttribute("data-amplitude-playlist"); 5874 var song = songBufferedProgressBars[i].getAttribute("data-amplitude-song-index"); 5875 5876 if (playlist == null && song == null && !isNaN(_config2.default.buffered)) { 5877 songBufferedProgressBars[i].value = parseFloat(parseFloat(_config2.default.buffered) / 100); 5878 } 5879 } 5880 } 5881 5882 /** 5883 * Sync the playlist song buffered progress elements. 5884 */ 5885 function syncPlaylist() { 5886 /* 5887 Gets all of the song buffered progress bars. 5888 */ 5889 var songBufferedProgressBarsPlaylist = document.querySelectorAll('.amplitude-buffered-progress[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 5890 5891 /* 5892 Iterate over all of the song buffered progress bar and 5893 set them to 0 which is like re-setting them. 5894 */ 5895 for (var i = 0; i < songBufferedProgressBarsPlaylist.length; i++) { 5896 var song = songBufferedProgressBarsPlaylist[i].getAttribute("data-amplitude-song-index"); 5897 5898 if (song == null && !isNaN(_config2.default.buffered)) { 5899 songBufferedProgressBarsPlaylist[i].value = parseFloat(parseFloat(_config2.default.buffered) / 100); 5900 } 5901 } 5902 } 5903 5904 /** 5905 * Sync the song song buffered progress elements. 5906 */ 5907 function syncSong() { 5908 /* 5909 Gets all of the song buffered progress bars. 5910 */ 5911 var songBufferedProgressBarsSongs = document.querySelectorAll('.amplitude-buffered-progress[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 5912 5913 /* 5914 Iterate over all of the song buffered progress bar and 5915 set them to 0 which is like re-setting them. 5916 */ 5917 for (var i = 0; i < songBufferedProgressBarsSongs.length; i++) { 5918 var playlist = songBufferedProgressBarsSongs[i].getAttribute("data-amplitude-playlist"); 5919 5920 if (playlist == null && !isNaN(_config2.default.buffered)) { 5921 songBufferedProgressBarsSongs[i].value = parseFloat(parseFloat(_config2.default.buffered) / 100); 5922 } 5923 } 5924 } 5925 5926 /** 5927 * Sync the song in playlist song buffered progress elements. 5928 */ 5929 function syncSongInPlaylist() { 5930 var activePlaylistIndex = _config2.default.active_playlist != null && _config2.default.active_playlist != "" ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 5931 5932 /* 5933 Gets all of the song buffered progress bars. 5934 */ 5935 var songBufferedProgressBarsSongsInPlaylist = document.querySelectorAll('.amplitude-buffered-progress[data-amplitude-song-index="' + activePlaylistIndex + '"][data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 5936 5937 /* 5938 Iterate over all of the song buffered progress bar and 5939 set them to 0 which is like re-setting them. 5940 */ 5941 for (var i = 0; i < songBufferedProgressBarsSongsInPlaylist.length; i++) { 5942 if (!isNaN(_config2.default.buffered)) { 5943 songBufferedProgressBarsSongsInPlaylist[i].value = parseFloat(parseFloat(_config2.default.buffered) / 100); 5944 } 5945 } 5946 } 5947 5948 /** 5949 * Sets all of the song buffered progress bars to 0 5950 * 5951 * @access public 5952 */ 5953 function reset() { 5954 /* 5955 Gets all of the song buffered progress bars. 5956 */ 5957 var songBufferedProgressBars = document.getElementsByClassName("amplitude-buffered-progress"); 5958 5959 /* 5960 Iterate over all of the song buffered progress bar and 5961 set them to 0 which is like re-setting them. 5962 */ 5963 for (var i = 0; i < songBufferedProgressBars.length; i++) { 5964 songBufferedProgressBars[i].value = 0; 5965 } 5966 } 5967 5968 /** 5969 * Returns the public facing methods 5970 */ 5971 return { 5972 sync: sync, 5973 reset: reset 5974 }; 5975}(); /** 5976 * Imports the config module 5977 * @module config 5978 */ 5979exports.default = BufferedProgressElements; 5980module.exports = exports["default"]; 5981 5982/***/ }), 5983/* 25 */ 5984/***/ (function(module, exports, __webpack_require__) { 5985 5986"use strict"; 5987 5988 5989Object.defineProperty(exports, "__esModule", { 5990 value: true 5991}); 5992 5993var _config = __webpack_require__(0); 5994 5995var _config2 = _interopRequireDefault(_config); 5996 5997var _audioNavigation = __webpack_require__(3); 5998 5999var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 6000 6001var _core = __webpack_require__(1); 6002 6003var _core2 = _interopRequireDefault(_core); 6004 6005var _playPauseElements = __webpack_require__(2); 6006 6007var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 6008 6009function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6010 6011/** 6012 * AmplitudeJS Ended Module. Handles the ended event on the audio. 6013 * 6014 * @module events/Ended 6015 */ 6016 6017 6018/** 6019 * Imports the AmplitudeJS Core Methods 6020 * @module core/Core 6021 */ 6022/** 6023 * Imports the config module 6024 * @module config 6025 */ 6026var Ended = function () { 6027 /** 6028 * When the song has ended, handles what to do next 6029 * 6030 * HANDLER FOR: ended 6031 * 6032 * @access public 6033 */ 6034 function handle() { 6035 /* 6036 Sets the time out for song ended. This determines if 6037 we should go to the next song or delay between songs. 6038 */ 6039 setTimeout(function () { 6040 /* 6041 If we continue next, we should move to the next song in the playlist. 6042 */ 6043 if (_config2.default.continue_next) { 6044 /* 6045 If the active playlist is not set, we set the 6046 next song that's in the songs array. 6047 */ 6048 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 6049 _audioNavigation2.default.setNext(true); 6050 } else { 6051 _audioNavigation2.default.setNextPlaylist(_config2.default.active_playlist, true); 6052 } 6053 } else { 6054 if (!_config2.default.is_touch_moving) { 6055 /* 6056 Stops the active song. 6057 */ 6058 _core2.default.stop(); 6059 6060 /* 6061 Sync the play pause elements. 6062 */ 6063 _playPauseElements2.default.sync(); 6064 } 6065 } 6066 }, _config2.default.delay); 6067 } 6068 6069 /* 6070 Returns the public facing methods. 6071 */ 6072 return { 6073 handle: handle 6074 }; 6075}(); 6076 6077/** 6078 * Imports the AmplitudeJS Play Pause Elements 6079 * @module visual/PlayPauseElements 6080 */ 6081 6082 6083/** 6084 * Imports the Audio Navigation Utility 6085 * @module utilities/AudioNavigation 6086 */ 6087exports.default = Ended; 6088module.exports = exports["default"]; 6089 6090/***/ }), 6091/* 26 */ 6092/***/ (function(module, exports, __webpack_require__) { 6093 6094"use strict"; 6095 6096 6097Object.defineProperty(exports, "__esModule", { 6098 value: true 6099}); 6100 6101var _config = __webpack_require__(0); 6102 6103var _config2 = _interopRequireDefault(_config); 6104 6105var _keydown = __webpack_require__(27); 6106 6107var _keydown2 = _interopRequireDefault(_keydown); 6108 6109var _timeUpdate = __webpack_require__(42); 6110 6111var _timeUpdate2 = _interopRequireDefault(_timeUpdate); 6112 6113var _ended = __webpack_require__(25); 6114 6115var _ended2 = _interopRequireDefault(_ended); 6116 6117var _progress = __webpack_require__(35); 6118 6119var _progress2 = _interopRequireDefault(_progress); 6120 6121var _play = __webpack_require__(31); 6122 6123var _play2 = _interopRequireDefault(_play); 6124 6125var _pause = __webpack_require__(30); 6126 6127var _pause2 = _interopRequireDefault(_pause); 6128 6129var _playPause = __webpack_require__(32); 6130 6131var _playPause2 = _interopRequireDefault(_playPause); 6132 6133var _stop = __webpack_require__(41); 6134 6135var _stop2 = _interopRequireDefault(_stop); 6136 6137var _mute = __webpack_require__(28); 6138 6139var _mute2 = _interopRequireDefault(_mute); 6140 6141var _volumeUp = __webpack_require__(45); 6142 6143var _volumeUp2 = _interopRequireDefault(_volumeUp); 6144 6145var _volumeDown = __webpack_require__(43); 6146 6147var _volumeDown2 = _interopRequireDefault(_volumeDown); 6148 6149var _songSlider = __webpack_require__(40); 6150 6151var _songSlider2 = _interopRequireDefault(_songSlider); 6152 6153var _volumeSlider = __webpack_require__(44); 6154 6155var _volumeSlider2 = _interopRequireDefault(_volumeSlider); 6156 6157var _next = __webpack_require__(29); 6158 6159var _next2 = _interopRequireDefault(_next); 6160 6161var _prev = __webpack_require__(34); 6162 6163var _prev2 = _interopRequireDefault(_prev); 6164 6165var _repeat = __webpack_require__(36); 6166 6167var _repeat2 = _interopRequireDefault(_repeat); 6168 6169var _repeatSong = __webpack_require__(37); 6170 6171var _repeatSong2 = _interopRequireDefault(_repeatSong); 6172 6173var _playbackSpeed = __webpack_require__(33); 6174 6175var _playbackSpeed2 = _interopRequireDefault(_playbackSpeed); 6176 6177var _shuffle = __webpack_require__(38); 6178 6179var _shuffle2 = _interopRequireDefault(_shuffle); 6180 6181var _skipTo = __webpack_require__(39); 6182 6183var _skipTo2 = _interopRequireDefault(_skipTo); 6184 6185var _waveform = __webpack_require__(22); 6186 6187var _waveform2 = _interopRequireDefault(_waveform); 6188 6189var _debug = __webpack_require__(4); 6190 6191var _debug2 = _interopRequireDefault(_debug); 6192 6193function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6194 6195/** 6196 * AmplitudeJS Events Module. Handles all of the events we listen to in 6197 * AmplitudeJS. 6198 * 6199 * @module events/Events 6200 */ 6201 6202 6203/** 6204 * Imports all of the handler objects used by the events. 6205 */ 6206var Events = function () { 6207 /** 6208 * Initializes the handlers for the events listened to by Amplitude 6209 * 6210 * @access public 6211 */ 6212 function initialize() { 6213 /* 6214 Write out debug message 6215 */ 6216 _debug2.default.writeMessage("Beginning initialization of event handlers.."); 6217 6218 /* 6219 Sets flag that the screen is moving and not a tap 6220 */ 6221 document.addEventListener("touchmove", function () { 6222 _config2.default.is_touch_moving = true; 6223 }); 6224 6225 /* 6226 On touch end if it was a touch move event, set moving to 6227 false 6228 */ 6229 document.addEventListener("touchend", function () { 6230 if (_config2.default.is_touch_moving) { 6231 _config2.default.is_touch_moving = false; 6232 } 6233 }); 6234 6235 /* 6236 On time update for the audio element, update visual displays that 6237 represent the time on either a visualized element or time display. 6238 */ 6239 bindTimeUpdate(); 6240 6241 /* 6242 Binds key down event handlers for matching key codes to functions. 6243 */ 6244 bindKeyDownEventHandlers(); 6245 6246 /* 6247 When the audio element has ended playing, we handle the song 6248 ending. In a single song or multiple modular song instance, 6249 this just synchronizes the visuals for time and song time 6250 visualization, but for a playlist it determines whether 6251 it should play the next song or not. 6252 */ 6253 bindSongEnded(); 6254 6255 /* 6256 Binds progress event so we can see how much of the song is loaded. 6257 */ 6258 bindProgress(); 6259 6260 /* 6261 Binds 'amplitude-play' event handlers 6262 */ 6263 bindPlay(); 6264 6265 /* 6266 Binds 'amplitude-pause' event handlers. 6267 */ 6268 bindPause(); 6269 6270 /* 6271 Binds 'amplitude-play-pause' event handlers. 6272 */ 6273 bindPlayPause(); 6274 6275 /* 6276 Binds 'amplitude-stop' event handlers. 6277 */ 6278 bindStop(); 6279 6280 /* 6281 Binds 'amplitude-mute' event handlers. 6282 */ 6283 bindMute(); 6284 6285 /* 6286 Binds 'amplitude-volume-up' event handlers 6287 */ 6288 bindVolumeUp(); 6289 6290 /* 6291 Binds 'amplitude-volume-down' event handlers 6292 */ 6293 bindVolumeDown(); 6294 6295 /* 6296 Binds 'amplitude-song-slider' event handlers 6297 */ 6298 bindSongSlider(); 6299 6300 /* 6301 Binds 'amplitude-volume-slider' event handlers. 6302 */ 6303 bindVolumeSlider(); 6304 6305 /* 6306 Binds 'amplitude-next' event handlers. 6307 */ 6308 bindNext(); 6309 6310 /* 6311 Binds 'amplitude-prev' event handlers. 6312 */ 6313 bindPrev(); 6314 6315 /* 6316 Binds 'amplitude-shuffle' event handlers. 6317 */ 6318 bindShuffle(); 6319 6320 /* 6321 Binds 'amplitude-repeat' event handlers. 6322 */ 6323 bindRepeat(); 6324 6325 /* 6326 Binds 'amplitude-repeat-song' event handlers. 6327 */ 6328 bindRepeatSong(); 6329 6330 /* 6331 Binds 'amplitude-playback-speed' event handlers. 6332 */ 6333 bindPlaybackSpeed(); 6334 6335 /* 6336 Binds 'amplitude-skip-to' event handlers. 6337 */ 6338 bindSkipTo(); 6339 6340 /* 6341 Binds `canplaythrough` event to build the waveform. 6342 */ 6343 bindCanPlayThrough(); 6344 } 6345 6346 /** 6347 * On time update for the audio element, update visual displays that 6348 * represent the time on either a visualized element or time display. 6349 * 6350 * @access private 6351 */ 6352 function bindTimeUpdate() { 6353 /* 6354 Bind for time update 6355 */ 6356 _config2.default.audio.removeEventListener("timeupdate", _timeUpdate2.default.handle); 6357 _config2.default.audio.addEventListener("timeupdate", _timeUpdate2.default.handle); 6358 6359 /* 6360 Bind for duration change 6361 */ 6362 _config2.default.audio.removeEventListener("durationchange", _timeUpdate2.default.handle); 6363 _config2.default.audio.addEventListener("durationchange", _timeUpdate2.default.handle); 6364 } 6365 6366 /** 6367 * On keydown, we listen to what key got pressed so we can map the key to 6368 * a function. This allows the user to map pause and play, next, etc. to key 6369 * presses. 6370 * 6371 * @access private 6372 */ 6373 function bindKeyDownEventHandlers() { 6374 document.removeEventListener("keydown", _keydown2.default.handle); 6375 document.addEventListener("keydown", _keydown2.default.handle); 6376 } 6377 6378 /** 6379 * When the audio element has ended playing, we handle the song 6380 * ending. In a single song or multiple modular song instance, 6381 * this just synchronizes the visuals for time and song time 6382 * visualization, but for a playlist it determines whether 6383 * it should play the next song or not. 6384 * 6385 * @access private 6386 */ 6387 function bindSongEnded() { 6388 _config2.default.audio.removeEventListener("ended", _ended2.default.handle); 6389 _config2.default.audio.addEventListener("ended", _ended2.default.handle); 6390 } 6391 6392 /** 6393 * As the audio is loaded, the progress event gets fired. We bind into this 6394 * to grab the buffered percentage of the song. We can then add more elements 6395 * to show the buffered amount. 6396 * 6397 * @access private 6398 */ 6399 function bindProgress() { 6400 _config2.default.audio.removeEventListener("progress", _progress2.default.handle); 6401 _config2.default.audio.addEventListener("progress", _progress2.default.handle); 6402 } 6403 6404 /** 6405 * Binds click and touchend events for AmplitudeJS play buttons 6406 * 6407 * @access private 6408 */ 6409 function bindPlay() { 6410 /* 6411 Gets all of the elements with the class amplitude-play 6412 */ 6413 var play_classes = document.getElementsByClassName("amplitude-play"); 6414 6415 /* 6416 Iterates over all of the play classes and binds the event interaction 6417 method to the element. If the browser is mobile, then the event is touchend 6418 otherwise it is click. 6419 */ 6420 for (var i = 0; i < play_classes.length; i++) { 6421 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6422 play_classes[i].removeEventListener("touchend", _play2.default.handle); 6423 play_classes[i].addEventListener("touchend", _play2.default.handle); 6424 } else { 6425 play_classes[i].removeEventListener("click", _play2.default.handle); 6426 play_classes[i].addEventListener("click", _play2.default.handle); 6427 } 6428 } 6429 } 6430 6431 /** 6432 * Binds click and touchend events for AmplitudeJS pause buttons. 6433 * 6434 * @access private 6435 */ 6436 function bindPause() { 6437 /* 6438 Gets all of the elements with the class amplitude-pause 6439 */ 6440 var pause_classes = document.getElementsByClassName("amplitude-pause"); 6441 6442 /* 6443 Iterates over all of the pause classes and binds the event interaction 6444 method to the element. If the browser is mobile, then the event is touchend 6445 otherwise it is click. 6446 */ 6447 for (var i = 0; i < pause_classes.length; i++) { 6448 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6449 pause_classes[i].removeEventListener("touchend", _pause2.default.handle); 6450 pause_classes[i].addEventListener("touchend", _pause2.default.handle); 6451 } else { 6452 pause_classes[i].removeEventListener("click", _pause2.default.handle); 6453 pause_classes[i].addEventListener("click", _pause2.default.handle); 6454 } 6455 } 6456 } 6457 6458 /** 6459 * Binds click and touchend events for AmplitudeJS play pause buttons 6460 * 6461 * @access private 6462 */ 6463 function bindPlayPause() { 6464 /* 6465 Gets all of the elements with the class amplitude-play-pause 6466 */ 6467 var play_pause_classes = document.getElementsByClassName("amplitude-play-pause"); 6468 6469 /* 6470 Iterates over all of the play/pause classes and binds the event interaction 6471 method to the element. If the browser is mobile, then the event is touchend 6472 otherwise it is click. 6473 */ 6474 for (var i = 0; i < play_pause_classes.length; i++) { 6475 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6476 play_pause_classes[i].removeEventListener("touchend", _playPause2.default.handle); 6477 play_pause_classes[i].addEventListener("touchend", _playPause2.default.handle); 6478 } else { 6479 play_pause_classes[i].removeEventListener("click", _playPause2.default.handle); 6480 play_pause_classes[i].addEventListener("click", _playPause2.default.handle); 6481 } 6482 } 6483 } 6484 6485 /** 6486 * Binds click and touchend events for AmplitudeJS stop buttons 6487 * 6488 * @access private 6489 */ 6490 function bindStop() { 6491 /* 6492 Gets all of the elements with the class amplitude-stop 6493 */ 6494 var stop_classes = document.getElementsByClassName("amplitude-stop"); 6495 6496 /* 6497 Iterates over all of the stop classes and binds the event interaction 6498 method to the element. If the browser is mobile, then the event is touchend 6499 otherwise it is click. 6500 */ 6501 for (var i = 0; i < stop_classes.length; i++) { 6502 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6503 stop_classes[i].removeEventListener("touchend", _stop2.default.handle); 6504 stop_classes[i].addEventListener("touchend", _stop2.default.handle); 6505 } else { 6506 stop_classes[i].removeEventListener("click", _stop2.default.handle); 6507 stop_classes[i].addEventListener("click", _stop2.default.handle); 6508 } 6509 } 6510 } 6511 6512 /** 6513 * Binds click and touchend events for AmplitudeJS mute buttons 6514 * 6515 * @access private 6516 */ 6517 function bindMute() { 6518 /* 6519 Gets all of the elements with the class amplitue-mute 6520 */ 6521 var mute_classes = document.getElementsByClassName("amplitude-mute"); 6522 6523 /* 6524 Iterates over all of the mute classes and binds the event interaction 6525 method to the element. If the browser is mobile, then the event is touchend 6526 otherwise it is click. 6527 */ 6528 for (var i = 0; i < mute_classes.length; i++) { 6529 /* 6530 WARNING: If iOS, we don't do anything because iOS does not allow the 6531 volume to be adjusted through anything except the buttons on the side of 6532 the device. 6533 */ 6534 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6535 /* 6536 Checks for an iOS device and displays an error message if debugging 6537 is turned on. 6538 */ 6539 if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { 6540 _debug2.default.writeMessage("iOS does NOT allow volume to be set through javascript: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW4"); 6541 } else { 6542 mute_classes[i].removeEventListener("touchend", _mute2.default.handle); 6543 mute_classes[i].addEventListener("touchend", _mute2.default.handle); 6544 } 6545 } else { 6546 mute_classes[i].removeEventListener("click", _mute2.default.handle); 6547 mute_classes[i].addEventListener("click", _mute2.default.handle); 6548 } 6549 } 6550 } 6551 6552 /** 6553 * Binds click and touchend events for AmplitudeJS Volume Up Buttons 6554 * 6555 * @access private 6556 */ 6557 function bindVolumeUp() { 6558 /* 6559 Gets all of the elements with the class amplitude-volume-up 6560 */ 6561 var volume_up_classes = document.getElementsByClassName("amplitude-volume-up"); 6562 6563 /* 6564 Iterates over all of the volume up classes and binds the event interaction 6565 methods to the element. If the browser is mobile, then the event is touchend 6566 otherwise it is click. 6567 */ 6568 for (var i = 0; i < volume_up_classes.length; i++) { 6569 /* 6570 WARNING: If iOS, we don't do anything because iOS does not allow the 6571 volume to be adjusted through anything except the buttons on the side of 6572 the device. 6573 */ 6574 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6575 /* 6576 Checks for an iOS device and displays an error message if debugging 6577 is turned on. 6578 */ 6579 if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { 6580 _debug2.default.writeMessage("iOS does NOT allow volume to be set through javascript: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW4"); 6581 } else { 6582 volume_up_classes[i].removeEventListener("touchend", _volumeUp2.default.handle); 6583 volume_up_classes[i].addEventListener("touchend", _volumeUp2.default.handle); 6584 } 6585 } else { 6586 volume_up_classes[i].removeEventListener("click", _volumeUp2.default.handle); 6587 volume_up_classes[i].addEventListener("click", _volumeUp2.default.handle); 6588 } 6589 } 6590 } 6591 6592 /** 6593 * Binds click and touchend events for AmplitudeJS Volume Down Buttons 6594 * 6595 * @access private 6596 */ 6597 function bindVolumeDown() { 6598 /* 6599 Gets all of the elements with the class amplitude-volume-down 6600 */ 6601 var volume_down_classes = document.getElementsByClassName("amplitude-volume-down"); 6602 6603 /* 6604 Iterates over all of the volume down classes and binds the event interaction 6605 methods to the element. If the browser is mobile, then the event is touchend 6606 otherwise it is click. 6607 */ 6608 for (var i = 0; i < volume_down_classes.length; i++) { 6609 /* 6610 WARNING: If iOS, we don't do anything because iOS does not allow the 6611 volume to be adjusted through anything except the buttons on the side of 6612 the device. 6613 */ 6614 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6615 /* 6616 Checks for an iOS device and displays an error message if debugging 6617 is turned on. 6618 */ 6619 if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { 6620 _debug2.default.writeMessage("iOS does NOT allow volume to be set through javascript: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW4"); 6621 } else { 6622 volume_down_classes[i].removeEventListener("touchend", _volumeDown2.default.handle); 6623 volume_down_classes[i].addEventListener("touchend", _volumeDown2.default.handle); 6624 } 6625 } else { 6626 volume_down_classes[i].removeEventListener("click", _volumeDown2.default.handle); 6627 volume_down_classes[i].addEventListener("click", _volumeDown2.default.handle); 6628 } 6629 } 6630 } 6631 6632 /** 6633 * Binds change and input events for AmplitudeJS Song Slider Inputs 6634 * 6635 * @access private 6636 */ 6637 function bindSongSlider() { 6638 /* 6639 Gets browser so if we need to apply overrides, like we usually 6640 have to do for anything cool in IE, we can do that. 6641 */ 6642 var ua = window.navigator.userAgent; 6643 var msie = ua.indexOf("MSIE "); 6644 6645 /* 6646 Gets all of the elements with the class amplitude-song-slider 6647 */ 6648 var song_sliders = document.getElementsByClassName("amplitude-song-slider"); 6649 6650 /* 6651 Iterates over all of the song slider classes and binds the event interaction 6652 methods to the element. If the browser is IE we listen to the change event 6653 where if it is anything else, it's the input method. 6654 */ 6655 for (var i = 0; i < song_sliders.length; i++) { 6656 if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { 6657 song_sliders[i].removeEventListener("change", _songSlider2.default.handle); 6658 song_sliders[i].addEventListener("change", _songSlider2.default.handle); 6659 } else { 6660 song_sliders[i].removeEventListener("input", _songSlider2.default.handle); 6661 song_sliders[i].addEventListener("input", _songSlider2.default.handle); 6662 } 6663 } 6664 } 6665 6666 /** 6667 * Binds change and input events fro AmplitudeJS Volume Slider inputs 6668 * 6669 * @access private 6670 */ 6671 function bindVolumeSlider() { 6672 /* 6673 Gets browser so if we need to apply overrides, like we usually 6674 have to do for anything cool in IE, we can do that. 6675 */ 6676 var ua = window.navigator.userAgent; 6677 var msie = ua.indexOf("MSIE "); 6678 6679 /* 6680 Gets all of the elements with the class amplitude-volume-slider 6681 */ 6682 var volume_sliders = document.getElementsByClassName("amplitude-volume-slider"); 6683 6684 /* 6685 Iterates over all of the volume slider classes and binds the event interaction 6686 methods to the element. If the browser is IE we listen to the change event 6687 where if it is anything else, it's the input method. 6688 */ 6689 for (var i = 0; i < volume_sliders.length; i++) { 6690 /* 6691 WARNING: If iOS, we don't do anything because iOS does not allow the 6692 volume to be adjusted through anything except the buttons on the side of 6693 the device. 6694 */ 6695 if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { 6696 _debug2.default.writeMessage("iOS does NOT allow volume to be set through javascript: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW4"); 6697 } else { 6698 if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { 6699 volume_sliders[i].removeEventListener("change", _volumeSlider2.default.handle); 6700 volume_sliders[i].addEventListener("change", _volumeSlider2.default.handle); 6701 } else { 6702 volume_sliders[i].removeEventListener("input", _volumeSlider2.default.handle); 6703 volume_sliders[i].addEventListener("input", _volumeSlider2.default.handle); 6704 } 6705 } 6706 } 6707 } 6708 6709 /** 6710 * Binds click and touchend events fro AmplitudeJS Next buttons 6711 * 6712 * @access private 6713 */ 6714 function bindNext() { 6715 /* 6716 Gets all of the elements with the class amplitude-next 6717 */ 6718 var next_classes = document.getElementsByClassName("amplitude-next"); 6719 6720 /* 6721 Iterates over all of the next classes and binds the event interaction 6722 methods to the element. If the browser is mobile, then the event is touchend 6723 otherwise it is click. 6724 */ 6725 for (var i = 0; i < next_classes.length; i++) { 6726 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6727 next_classes[i].removeEventListener("touchend", _next2.default.handle); 6728 next_classes[i].addEventListener("touchend", _next2.default.handle); 6729 } else { 6730 next_classes[i].removeEventListener("click", _next2.default.handle); 6731 next_classes[i].addEventListener("click", _next2.default.handle); 6732 } 6733 } 6734 } 6735 6736 /** 6737 * Binds click and touchend events for AmplitudeJS prev buttons. 6738 * 6739 * @access private 6740 */ 6741 function bindPrev() { 6742 /* 6743 Gets all of the elements with the class amplitude-prev 6744 */ 6745 var prev_classes = document.getElementsByClassName("amplitude-prev"); 6746 6747 /* 6748 Iterates over all of the prev classes and binds the event interaction 6749 methods to the element. If the browser is mobile, then the event is touchend 6750 otherwise it is click. 6751 */ 6752 for (var i = 0; i < prev_classes.length; i++) { 6753 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6754 prev_classes[i].removeEventListener("touchend", _prev2.default.handle); 6755 prev_classes[i].addEventListener("touchend", _prev2.default.handle); 6756 } else { 6757 prev_classes[i].removeEventListener("click", _prev2.default.handle); 6758 prev_classes[i].addEventListener("click", _prev2.default.handle); 6759 } 6760 } 6761 } 6762 6763 /** 6764 * Binds click and touchend events for AmplitudeJS shuffle buttons. 6765 * 6766 * @access private 6767 */ 6768 function bindShuffle() { 6769 /* 6770 Gets all of the elements with the class amplitude-shuffle 6771 */ 6772 var shuffle_classes = document.getElementsByClassName("amplitude-shuffle"); 6773 6774 /* 6775 Iterates over all of the shuffle classes and binds the event interaction 6776 methods to the element. If the browser is mobile, then the event is touchend 6777 otherwise it is click. 6778 */ 6779 for (var i = 0; i < shuffle_classes.length; i++) { 6780 /* 6781 Since we are re-binding everything we remove any classes that signify 6782 a state of the shuffle control. 6783 */ 6784 shuffle_classes[i].classList.remove("amplitude-shuffle-on"); 6785 shuffle_classes[i].classList.add("amplitude-shuffle-off"); 6786 6787 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6788 shuffle_classes[i].removeEventListener("touchend", _shuffle2.default.handle); 6789 shuffle_classes[i].addEventListener("touchend", _shuffle2.default.handle); 6790 } else { 6791 shuffle_classes[i].removeEventListener("click", _shuffle2.default.handle); 6792 shuffle_classes[i].addEventListener("click", _shuffle2.default.handle); 6793 } 6794 } 6795 } 6796 6797 /** 6798 * Binds click and touchend events for AmplitudeJS repeat buttons. 6799 * 6800 * @access private 6801 */ 6802 function bindRepeat() { 6803 /* 6804 Gets all of the elements with the class amplitude-repeat 6805 */ 6806 var repeat_classes = document.getElementsByClassName("amplitude-repeat"); 6807 6808 /* 6809 Iterates over all of the repeat classes and binds the event interaction 6810 methods to the element. If the browser is mobile, then the event is touchend 6811 otherwise it is click. 6812 */ 6813 for (var i = 0; i < repeat_classes.length; i++) { 6814 /* 6815 Since we are re-binding everything we remove any classes that signify 6816 a state of the repeat control. 6817 */ 6818 repeat_classes[i].classList.remove("amplitude-repeat-on"); 6819 repeat_classes[i].classList.add("amplitude-repeat-off"); 6820 6821 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6822 repeat_classes[i].removeEventListener("touchend", _repeat2.default.handle); 6823 repeat_classes[i].addEventListener("touchend", _repeat2.default.handle); 6824 } else { 6825 repeat_classes[i].removeEventListener("click", _repeat2.default.handle); 6826 repeat_classes[i].addEventListener("click", _repeat2.default.handle); 6827 } 6828 } 6829 } 6830 6831 /** 6832 * Binds click and touchend events for AmplitudeJS repeat song buttons. 6833 * 6834 * @access private 6835 */ 6836 function bindRepeatSong() { 6837 /* 6838 Gets all of the elements with the class amplitude-repeat-song 6839 */ 6840 var repeat_song_classes = document.getElementsByClassName("amplitude-repeat-song"); 6841 6842 /* 6843 Iterates over all of the repeat song classes and binds the event interaction 6844 methods to the element. If the browser is mobile, then the event is touchend 6845 otherwise it is click. 6846 */ 6847 for (var i = 0; i < repeat_song_classes.length; i++) { 6848 /* 6849 Since we are re-binding everything we remove any classes that signify 6850 a state of the repeat control. 6851 */ 6852 repeat_song_classes[i].classList.remove("amplitude-repeat-on"); 6853 repeat_song_classes[i].classList.add("amplitude-repeat-off"); 6854 6855 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6856 repeat_song_classes[i].removeEventListener("touchend", _repeatSong2.default.handle); 6857 repeat_song_classes[i].addEventListener("touchend", _repeatSong2.default.handle); 6858 } else { 6859 repeat_song_classes[i].removeEventListener("click", _repeatSong2.default.handle); 6860 repeat_song_classes[i].addEventListener("click", _repeatSong2.default.handle); 6861 } 6862 } 6863 } 6864 6865 /** 6866 * Binds click and touchend events for AmplitudeJS playback speed buttons 6867 * 6868 * @access private 6869 */ 6870 function bindPlaybackSpeed() { 6871 /* 6872 Gets all of the elements with the class amplitude-playback-speed 6873 */ 6874 var playback_speed_classes = document.getElementsByClassName("amplitude-playback-speed"); 6875 6876 /* 6877 Iterates over all of the playback speed classes and binds the event interaction 6878 methods to the element. If the browser is mobile, then the event is touchend 6879 otherwise it is click. 6880 */ 6881 for (var i = 0; i < playback_speed_classes.length; i++) { 6882 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6883 playback_speed_classes[i].removeEventListener("touchend", _playbackSpeed2.default.handle); 6884 playback_speed_classes[i].addEventListener("touchend", _playbackSpeed2.default.handle); 6885 } else { 6886 playback_speed_classes[i].removeEventListener("click", _playbackSpeed2.default.handle); 6887 playback_speed_classes[i].addEventListener("click", _playbackSpeed2.default.handle); 6888 } 6889 } 6890 } 6891 6892 /** 6893 * Binds click and touchend events for AmplitudeJS skip to buttons. 6894 * 6895 * @access private 6896 */ 6897 function bindSkipTo() { 6898 /* 6899 Gets all of the skip to elements with the class 'amplitude-skip-to' 6900 */ 6901 var skipToClasses = document.getElementsByClassName("amplitude-skip-to"); 6902 6903 /* 6904 Iterates over all of the skip to classes and binds the event interaction 6905 methods to the element. If the browser is mobile, then the event is touchend 6906 otherwise it's a click. 6907 */ 6908 for (var i = 0; i < skipToClasses.length; i++) { 6909 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 6910 skipToClasses[i].removeEventListener("touchend", _skipTo2.default.handle); 6911 skipToClasses[i].addEventListener("touchend", _skipTo2.default.handle); 6912 } else { 6913 skipToClasses[i].removeEventListener("click", _skipTo2.default.handle); 6914 skipToClasses[i].addEventListener("click", _skipTo2.default.handle); 6915 } 6916 } 6917 } 6918 6919 /** 6920 * Binds can play through to a song. 6921 * 6922 * @access private 6923 */ 6924 function bindCanPlayThrough() { 6925 if (_waveform2.default.determineIfUsingWaveforms()) { 6926 _config2.default.audio.removeEventListener("canplaythrough", _waveform2.default.build); 6927 _config2.default.audio.addEventListener("canplaythrough", _waveform2.default.build); 6928 } 6929 } 6930 6931 /* 6932 Returns the public facing functions. 6933 */ 6934 return { 6935 initialize: initialize 6936 }; 6937}(); 6938 6939/** 6940 * Imports the utility classes used by the evnets. 6941 */ 6942/* 6943 Import the necessary classes and config to use 6944 with the events. 6945*/ 6946exports.default = Events; 6947module.exports = exports["default"]; 6948 6949/***/ }), 6950/* 27 */ 6951/***/ (function(module, exports, __webpack_require__) { 6952 6953"use strict"; 6954 6955 6956Object.defineProperty(exports, "__esModule", { 6957 value: true 6958}); 6959 6960var _config = __webpack_require__(0); 6961 6962var _config2 = _interopRequireDefault(_config); 6963 6964var _core = __webpack_require__(1); 6965 6966var _core2 = _interopRequireDefault(_core); 6967 6968var _shuffler = __webpack_require__(13); 6969 6970var _shuffler2 = _interopRequireDefault(_shuffler); 6971 6972var _repeater = __webpack_require__(12); 6973 6974var _repeater2 = _interopRequireDefault(_repeater); 6975 6976var _audioNavigation = __webpack_require__(3); 6977 6978var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 6979 6980var _repeatElements = __webpack_require__(8); 6981 6982var _repeatElements2 = _interopRequireDefault(_repeatElements); 6983 6984var _playPauseElements = __webpack_require__(2); 6985 6986var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 6987 6988function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6989 6990/** 6991 * AmplitudeJS Key Down event handler 6992 * 6993 * @module events/KeyDown 6994 */ 6995 6996 6997/** 6998 * Imports the Repeat Elements Visual Handler 6999 * @module visual/RepeatElements 7000 */ 7001 7002 7003/** 7004 * Imports the Repeater Utility 7005 * @module utilities/Repeater 7006 */ 7007 7008 7009/** 7010 * Imports the core of AmplitudeJS 7011 * @module core/Core 7012 */ 7013var KeyDown = function () { 7014 /** 7015 * When the keydown event is fired, we determine which function should be run 7016 * based on what was passed in. 7017 * 7018 * HANDLER FOR: keydown 7019 * 7020 * @access public 7021 * @prop {object} event The event object being passed in. 7022 */ 7023 function handle(event) { 7024 runKeyEvent(event.which); 7025 } 7026 7027 /** 7028 * Runs an event on key down 7029 * 7030 * @access public 7031 * @param {number} key - The key code the event is bound to. 7032 */ 7033 function runKeyEvent(key) { 7034 /* 7035 Checks to see if the user bound an event to the code pressed. 7036 */ 7037 if (_config2.default.bindings[key] != undefined) { 7038 /* 7039 Determine which event should be run if bound. 7040 */ 7041 switch (_config2.default.bindings[key]) { 7042 /* 7043 Fires a play pause event. 7044 */ 7045 case "play_pause": 7046 runPlayPauseKeyDownEvent(); 7047 break; 7048 7049 /* 7050 Fires a next event. 7051 */ 7052 case "next": 7053 runNextKeyDownEvent(); 7054 break; 7055 7056 /* 7057 Fires a previous event. 7058 */ 7059 case "prev": 7060 runPrevKeyDownEvent(); 7061 break; 7062 7063 /* 7064 Fires a stop event. 7065 */ 7066 case "stop": 7067 runStopKeyDownEvent(); 7068 break; 7069 7070 /* 7071 Fires a shuffle event. 7072 */ 7073 case "shuffle": 7074 runShuffleKeyDownEvent(); 7075 break; 7076 7077 /* 7078 Fires a repeat event. 7079 */ 7080 case "repeat": 7081 runRepeatKeyDownEvent(); 7082 break; 7083 } 7084 } 7085 } 7086 7087 /** 7088 * Runs the play pause method for key down. 7089 */ 7090 function runPlayPauseKeyDownEvent() { 7091 /* 7092 If the song is paused, we play the song. If the song is playing, 7093 we pause the song. 7094 */ 7095 if (_config2.default.audio.paused) { 7096 _core2.default.play(); 7097 } else { 7098 _core2.default.pause(); 7099 } 7100 7101 /* 7102 Now we sync all the elements to match the state of the audio. 7103 We don't need to do any checks on new songs or changed playlists 7104 in the global since it's whatever song is playing. 7105 */ 7106 _playPauseElements2.default.sync(); 7107 } 7108 7109 /** 7110 * Runs the next method for key down. 7111 */ 7112 function runNextKeyDownEvent() { 7113 /* 7114 Check to see if the current state of the player 7115 is in playlist mode or not playlist mode. 7116 */ 7117 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 7118 _audioNavigation2.default.setNext(); 7119 } else { 7120 _audioNavigation2.default.setNextPlaylist(_config2.default.active_playlist); 7121 } 7122 } 7123 7124 /** 7125 * Runs the previous method for key down. 7126 */ 7127 function runPrevKeyDownEvent() { 7128 /* 7129 Check to see if the current playlist has been set 7130 or null and set the previous song. 7131 */ 7132 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 7133 _audioNavigation2.default.setPrevious(); 7134 } else { 7135 _audioNavigation2.default.setPreviousPlaylist(_config2.default.active_playlist); 7136 } 7137 } 7138 7139 /** 7140 * Runs the stop method for key down. 7141 */ 7142 function runStopKeyDownEvent() { 7143 /* 7144 Syncs all of the play pause elements to pause. 7145 */ 7146 _playPauseElements2.default.syncToPause(); 7147 7148 /* 7149 Stops the active song. 7150 */ 7151 _core2.default.stop(); 7152 } 7153 7154 /** 7155 * Runs the shuffle method for key down. 7156 */ 7157 function runShuffleKeyDownEvent() { 7158 /* 7159 Check to see if the current playlist has been set 7160 or null and set the previous song. 7161 */ 7162 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 7163 _shuffler2.default.toggleShuffle(); 7164 } else { 7165 _shuffler2.default.toggleShufflePlaylist(_config2.default.active_playlist); 7166 } 7167 } 7168 7169 /** 7170 * Run the repeat method for key down. 7171 */ 7172 function runRepeatKeyDownEvent() { 7173 /* 7174 Toggles the repeat 7175 */ 7176 _repeater2.default.setRepeat(!_config2.default.repeat); 7177 7178 /* 7179 Visually sync repeat 7180 */ 7181 _repeatElements2.default.syncRepeat(); 7182 } 7183 7184 /** 7185 * Returns the public methods for the handler. 7186 */ 7187 return { 7188 handle: handle 7189 }; 7190}(); 7191 7192/** 7193 * Imports the Play Pause Elements Visual Handler 7194 * @module visual/PlayPauseElements 7195 */ 7196 7197 7198/** 7199 * Imports the Audio Navigation Utility 7200 * @module utilities/AudioNavigation 7201 */ 7202 7203 7204/** 7205 * Imports the Shuffle Utility 7206 * @module utilities/Shuffle 7207 */ 7208/** 7209 * Imports the config module 7210 * @module config 7211 */ 7212exports.default = KeyDown; 7213module.exports = exports["default"]; 7214 7215/***/ }), 7216/* 28 */ 7217/***/ (function(module, exports, __webpack_require__) { 7218 7219"use strict"; 7220 7221 7222Object.defineProperty(exports, "__esModule", { 7223 value: true 7224}); 7225 7226var _config = __webpack_require__(0); 7227 7228var _config2 = _interopRequireDefault(_config); 7229 7230var _core = __webpack_require__(1); 7231 7232var _core2 = _interopRequireDefault(_core); 7233 7234var _muteElements = __webpack_require__(10); 7235 7236var _muteElements2 = _interopRequireDefault(_muteElements); 7237 7238var _volumeSliderElements = __webpack_require__(11); 7239 7240var _volumeSliderElements2 = _interopRequireDefault(_volumeSliderElements); 7241 7242function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7243 7244/** 7245 * Handles all events for a mute event. 7246 * @module events/Mute 7247 */ 7248 7249 7250/** 7251 * Imports the AmplitudeJS Visual Mute Elements 7252 * @module visual/MuteElements 7253 */ 7254/** 7255 * Imports the config to use the values 7256 */ 7257var Mute = function () { 7258 /** 7259 * Handles an event for a mute element 7260 * 7261 * HANDLER FOR: class="amplitude-mute" 7262 * 7263 * @access public 7264 */ 7265 function handle() { 7266 /* 7267 We don't fire this if the user is touching the screen and it's moving. 7268 This could lead to a mis-fire 7269 */ 7270 if (!_config2.default.is_touch_moving) { 7271 /* 7272 If the current volume in the config is 0, we set the volume to the 7273 pre_mute level. This means that the audio is already muted and 7274 needs to be restored to the pre_mute level. 7275 Otherwise, we set pre_mute volume to the current volume 7276 and set the config volume to 0, muting the audio. 7277 */ 7278 if (_config2.default.volume == 0) { 7279 _core2.default.setVolume(_config2.default.pre_mute_volume); 7280 } else { 7281 _config2.default.pre_mute_volume = _config2.default.volume; 7282 _core2.default.setVolume(0); 7283 } 7284 7285 /* 7286 Sync Mute Elements. 7287 */ 7288 _muteElements2.default.setMuted(_config2.default.volume == 0 ? true : false); 7289 7290 /* 7291 Syncs the volume sliders so the visuals align up with the functionality. 7292 If the volume is at 0, then the sliders should represent that so the user 7293 has the right starting point. 7294 */ 7295 _volumeSliderElements2.default.sync(); 7296 } 7297 } 7298 7299 /** 7300 * Returns the public facing methods 7301 */ 7302 return { 7303 handle: handle 7304 }; 7305}(); 7306 7307/** 7308 * Imports the AmplitudeJS Visual Volume Slider Elements 7309 * @module visual/VolumeSliderElements 7310 */ 7311 7312 7313/** 7314 * Imports the AmplitudeJS Core Methods 7315 * @module core/core 7316 */ 7317exports.default = Mute; 7318module.exports = exports["default"]; 7319 7320/***/ }), 7321/* 29 */ 7322/***/ (function(module, exports, __webpack_require__) { 7323 7324"use strict"; 7325 7326 7327Object.defineProperty(exports, "__esModule", { 7328 value: true 7329}); 7330 7331var _config = __webpack_require__(0); 7332 7333var _config2 = _interopRequireDefault(_config); 7334 7335var _core = __webpack_require__(1); 7336 7337var _core2 = _interopRequireDefault(_core); 7338 7339var _playPauseElements = __webpack_require__(2); 7340 7341var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 7342 7343var _callbacks = __webpack_require__(9); 7344 7345var _callbacks2 = _interopRequireDefault(_callbacks); 7346 7347var _audioNavigation = __webpack_require__(3); 7348 7349var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 7350 7351var _debug = __webpack_require__(4); 7352 7353var _debug2 = _interopRequireDefault(_debug); 7354 7355function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7356 7357/** 7358 * AmplitudeJS Next Event Handler 7359 * 7360 * @module events/Next 7361 */ 7362 7363 7364/** 7365 * Imports the Amplitude Audio Navigation Utility 7366 * @module utilities/AudioNavigation 7367 */ 7368 7369 7370/** 7371 * Imports the Play Pause Elements Module. 7372 * @module visual/PlayPauseElements 7373 */ 7374/** 7375 * Imports the config module 7376 * @module config 7377 */ 7378var Next = function () { 7379 /** 7380 * Handles an event on the next button 7381 * 7382 * HANDLER FOR: class="amplitude-next" 7383 * 7384 * GLOBAL: class="amplitude-next" 7385 * PLAYLIST: class="amplitude-next" amplitude-playlist="playlist_key" 7386 * 7387 * @access public 7388 */ 7389 function handle() { 7390 /* 7391 We don't fire this if the user is touching the screen and it's moving. 7392 This could lead to a mis-fire 7393 */ 7394 if (!_config2.default.is_touch_moving) { 7395 /* 7396 Gets the playlist attribute from the element. 7397 */ 7398 var playlist = this.getAttribute("data-amplitude-playlist"); 7399 7400 /* 7401 If the playlist is null, we handle the global next. 7402 */ 7403 if (playlist == null) { 7404 handleGlobalNext(); 7405 } 7406 7407 /* 7408 If the playlist is set, we handle the playlist next. 7409 */ 7410 if (playlist != null) { 7411 handlePlaylistNext(playlist); 7412 } 7413 } 7414 } 7415 7416 /** 7417 * Handles an event on a global enxt button. 7418 * 7419 * @access private 7420 */ 7421 function handleGlobalNext() { 7422 /* 7423 Check to see if the current state of the player 7424 is in playlist mode or not playlist mode. If we are in playlist mode, 7425 we set next on the playlist. 7426 */ 7427 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 7428 _audioNavigation2.default.setNext(); 7429 } else { 7430 _audioNavigation2.default.setNextPlaylist(_config2.default.active_playlist); 7431 } 7432 } 7433 7434 /** 7435 * Handles an event on a next playlist button. 7436 * 7437 * @access private 7438 * @prop {string} playlist - The playlist we are handling the next for. 7439 */ 7440 function handlePlaylistNext(playlist) { 7441 /* 7442 Ensure the playlist is the same as the active playlist. To get to change 7443 the scope to a new playlist, you need to play that playlist. 7444 */ 7445 if (playlist == _config2.default.active_playlist) { 7446 _audioNavigation2.default.setNextPlaylist(playlist); 7447 } else { 7448 _debug2.default.writeMessage("You can not go to the next song on a playlist that is not being played!"); 7449 } 7450 } 7451 7452 /* 7453 Returns the public facing methods. 7454 */ 7455 return { 7456 handle: handle 7457 }; 7458}(); 7459 7460/** 7461 * AmplitudeJS Debug Module 7462 * @module utilities/Debug 7463 */ 7464 7465 7466/** 7467 * Imports the Callbacks Module 7468 * @module utilities/Callbacks 7469 */ 7470 7471 7472/** 7473 * Imports the AmplitudeJS Core module. 7474 * @module core/core 7475 */ 7476exports.default = Next; 7477module.exports = exports["default"]; 7478 7479/***/ }), 7480/* 30 */ 7481/***/ (function(module, exports, __webpack_require__) { 7482 7483"use strict"; 7484 7485 7486Object.defineProperty(exports, "__esModule", { 7487 value: true 7488}); 7489 7490var _config = __webpack_require__(0); 7491 7492var _config2 = _interopRequireDefault(_config); 7493 7494var _configState = __webpack_require__(6); 7495 7496var _configState2 = _interopRequireDefault(_configState); 7497 7498var _core = __webpack_require__(1); 7499 7500var _core2 = _interopRequireDefault(_core); 7501 7502var _playPauseElements = __webpack_require__(2); 7503 7504var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 7505 7506function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7507 7508/** 7509 * Handles all of the pause events 7510 * @module events/Pause 7511 */ 7512 7513 7514/** 7515 * Imports the AmplitudeJS Core Methods 7516 * @module core/Core 7517 */ 7518/** 7519 * Imports the config module 7520 * @module config 7521 */ 7522var Pause = function () { 7523 /** 7524 * Handles an event on a pause button 7525 * 7526 * HANDLER FOR: class="amplitude-pause" 7527 * 7528 * GLOBAL: class="amplitude-pause" 7529 * PLAYLIST: class="amplitude-pause" amplitude-playlist="playlist_key" 7530 * SONG: class="amplitude-pause" amplitude-song-index="song_index" 7531 * SONG IN PLAYLIST: class="amplitude-pause" amplitude-playlist="playlist-key" amplitude-song-index="playlist_index" 7532 * 7533 * @access public 7534 */ 7535 function handle() { 7536 /* 7537 If the touch is moving, we do not want to accidentally touch the play 7538 pause element and fire an event. 7539 */ 7540 if (!_config2.default.is_touch_moving) { 7541 /* 7542 Gets the attribute for song index so we can check if 7543 there is a need to change the song. In some scenarios 7544 there might be multiple pause classes on the page. In that 7545 case it is possible the user could click a different pause 7546 class. 7547 */ 7548 var songIndexAttribute = this.getAttribute("data-amplitude-song-index"); 7549 var playlistAttribute = this.getAttribute("data-amplitude-playlist"); 7550 7551 /* 7552 Handle a global pause button. 7553 */ 7554 if (playlistAttribute == null && songIndexAttribute == null) { 7555 handleGlobalPause(); 7556 } 7557 7558 /* 7559 Handle a playlist pause button. 7560 */ 7561 if (playlistAttribute != null && songIndexAttribute == null) { 7562 handlePlaylistPause(playlistAttribute); 7563 } 7564 7565 /* 7566 Handle a song pause button. 7567 */ 7568 if (playlistAttribute == null && songIndexAttribute != null) { 7569 handleSongPause(songIndexAttribute); 7570 } 7571 7572 /* 7573 Handle a song in playlist pause button. 7574 */ 7575 if (playlistAttribute != null && songIndexAttribute != null) { 7576 handleSongInPlaylistPause(playlistAttribute, songIndexAttribute); 7577 } 7578 } 7579 } 7580 7581 /** 7582 * Handles global pause button which pauses whatever song is 7583 * active. 7584 * 7585 * @access private 7586 */ 7587 function handleGlobalPause() { 7588 /* 7589 Pauses the song. 7590 */ 7591 _core2.default.pause(); 7592 7593 /* 7594 Sync the play pause elements. 7595 */ 7596 _playPauseElements2.default.sync(); 7597 } 7598 7599 /** 7600 * Handles the playlist pause. 7601 * 7602 * @access private 7603 * @param {string} playlist The playlist the pause button belongs to. 7604 */ 7605 function handlePlaylistPause(playlist) { 7606 /* 7607 Checks to see if the active playlist is the same 7608 */ 7609 if (_config2.default.active_playlist == playlist) { 7610 /* 7611 Pauses the song. 7612 */ 7613 _core2.default.pause(); 7614 7615 /* 7616 Sync the play pause elements. 7617 */ 7618 _playPauseElements2.default.sync(); 7619 } 7620 } 7621 7622 /** 7623 * Handles the song pause. 7624 * 7625 * @access private 7626 * @param {integer} song The song the pause button belongs to. 7627 */ 7628 function handleSongPause(song) { 7629 /* 7630 Checks to see if the active playlist is null and the song matches 7631 the active index. 7632 */ 7633 if ((_config2.default.active_playlist == "" || _config2.default.active_playlist == null) && _config2.default.active_index == song) { 7634 /* 7635 Pauses the song. 7636 */ 7637 _core2.default.pause(); 7638 7639 /* 7640 Sync the play pause elements. 7641 */ 7642 _playPauseElements2.default.sync(); 7643 } 7644 } 7645 7646 /** 7647 * Handles the song in playlist pause. 7648 * 7649 * @access private 7650 * @param {string} playlist The playlist the pause button belongs to. 7651 * @param {integer} song The song the pause button belongs to. 7652 */ 7653 function handleSongInPlaylistPause(playlist, song) { 7654 /* 7655 Checks to see if the active song matches the song and the 7656 active playlist matches the playlist. This means the pause button is 7657 for the song in the playlist. 7658 */ 7659 if (_config2.default.active_playlist == playlist && _config2.default.playlists[playlist].active_index == song) { 7660 /* 7661 Pauses the song. 7662 */ 7663 _core2.default.pause(); 7664 7665 /* 7666 Sync the play pause elements. 7667 */ 7668 _playPauseElements2.default.sync(); 7669 } 7670 } 7671 7672 /* 7673 Returns the public facing elements 7674 */ 7675 return { 7676 handle: handle 7677 }; 7678}(); 7679 7680/** 7681 * Imports the AmplitudeJS Play Pause Elements 7682 * @module visual/PlayPauseElements 7683 */ 7684 7685 7686/** 7687 * Imports the ConfigState module. 7688 * @module utilities/ConfigState 7689 */ 7690exports.default = Pause; 7691module.exports = exports["default"]; 7692 7693/***/ }), 7694/* 31 */ 7695/***/ (function(module, exports, __webpack_require__) { 7696 7697"use strict"; 7698 7699 7700Object.defineProperty(exports, "__esModule", { 7701 value: true 7702}); 7703 7704var _config = __webpack_require__(0); 7705 7706var _config2 = _interopRequireDefault(_config); 7707 7708var _configState = __webpack_require__(6); 7709 7710var _configState2 = _interopRequireDefault(_configState); 7711 7712var _core = __webpack_require__(1); 7713 7714var _core2 = _interopRequireDefault(_core); 7715 7716var _checks = __webpack_require__(5); 7717 7718var _checks2 = _interopRequireDefault(_checks); 7719 7720var _audioNavigation = __webpack_require__(3); 7721 7722var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 7723 7724var _playPauseElements = __webpack_require__(2); 7725 7726var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 7727 7728function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7729 7730/** 7731 * Handles all of the play events 7732 * @module events/Play 7733 */ 7734 7735 7736/** 7737 * Imports the AmplitudeJS Audio Navigation Utility 7738 * @module utilities/AudioNavigation 7739 */ 7740 7741 7742/** 7743 * Imports the AmplitudeJS Core Methods 7744 * @module core/Core 7745 */ 7746/** 7747 * Imports the config module 7748 * @module config 7749 */ 7750var Play = function () { 7751 /** 7752 * Handles an event on a play button in Amplitude. 7753 * 7754 * HANDLER FOR: class="amplitude-play" 7755 * 7756 * GLOBAL: class="amplitude-play" 7757 * PLAYLIST: class="amplitude-play" amplitude-playlist="playlist_key" 7758 * SONG: class="amplitude-play" amplitude-song-index="song_index" 7759 * SONG IN PLAYLIST: class="amplitude-play" amplitude-playlist="playlist-key" amplitude-song-index="playlist_index" 7760 * 7761 * @access public 7762 */ 7763 function handle() { 7764 /* 7765 If the touch is moving, we do not want to accidentally touch the play 7766 pause element and fire an event. 7767 */ 7768 if (!_config2.default.is_touch_moving) { 7769 /* 7770 Gets the attribute for song index so we can check if 7771 there is a need to change the song. In some scenarios 7772 there might be multiple play classes on the page. In that 7773 case it is possible the user could click a different play 7774 class and change the song. 7775 */ 7776 var songIndexAttribute = this.getAttribute("data-amplitude-song-index"); 7777 var playlistAttribute = this.getAttribute("data-amplitude-playlist"); 7778 7779 /* 7780 Handle a global play button. 7781 */ 7782 if (playlistAttribute == null && songIndexAttribute == null) { 7783 handleGlobalPlay(); 7784 } 7785 7786 /* 7787 Handle a playlist play button. 7788 */ 7789 if (playlistAttribute != null && songIndexAttribute == null) { 7790 handlePlaylistPlay(playlistAttribute); 7791 } 7792 7793 /* 7794 Handle a song play button. 7795 */ 7796 if (playlistAttribute == null && songIndexAttribute != null) { 7797 handleSongPlay(songIndexAttribute); 7798 } 7799 7800 /* 7801 Handle a song in playlist play button. 7802 */ 7803 if (playlistAttribute != null && songIndexAttribute != null) { 7804 handleSongInPlaylistPlay(playlistAttribute, songIndexAttribute); 7805 } 7806 } 7807 } 7808 7809 /** 7810 * Handles global play button which plays whatever song is 7811 * active. 7812 * 7813 * @access private 7814 */ 7815 function handleGlobalPlay() { 7816 /* 7817 Plays the song 7818 */ 7819 _core2.default.play(); 7820 7821 /* 7822 Sync the play pause elements. 7823 */ 7824 _playPauseElements2.default.sync(); 7825 } 7826 7827 /** 7828 * Handle the playlist play. 7829 * 7830 * @access private 7831 * @param {string} playlist The playlist the play button belongs to. 7832 */ 7833 function handlePlaylistPlay(playlist) { 7834 /* 7835 Checks if we have a new playlist. 7836 */ 7837 if (_checks2.default.newPlaylist(playlist)) { 7838 /* 7839 Sets the active playlist to what belongs to the playlist. 7840 */ 7841 _audioNavigation2.default.setActivePlaylist(playlist); 7842 7843 /* 7844 Play first song in the playlist since we just 7845 switched playlists, we start from the first song. 7846 If the user has shuffle on for the playlist, then 7847 we go from the first song in the shuffle playlist array. 7848 */ 7849 if (_config2.default.playlists[playlist].shuffle) { 7850 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].shuffle_list[0], 0); 7851 } else { 7852 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[0], 0); 7853 } 7854 } 7855 7856 /* 7857 Plays the song. 7858 */ 7859 _core2.default.play(); 7860 7861 /* 7862 Syncs the play pause elements since they are dependent upon this state 7863 of the player. 7864 */ 7865 _playPauseElements2.default.sync(); 7866 } 7867 7868 /** 7869 * Handles the song play button. 7870 * 7871 * @access private 7872 * @param {integer} song The index of the song we are playing. 7873 */ 7874 function handleSongPlay(song) { 7875 /* 7876 There can be multiple playlists on the page and there can be 7877 multiple songs on the page AND there can be songs in multiple 7878 playlists, so we have some checking to do. 7879 */ 7880 7881 /* 7882 Check to see if the playlist has changed. Essentially, if we are moving 7883 out of a playlist context. 7884 */ 7885 if (_checks2.default.newPlaylist(null)) { 7886 /* 7887 We've moved out of the playlist context, so we set the active playlist 7888 to null 7889 */ 7890 _audioNavigation2.default.setActivePlaylist(null); 7891 7892 /* 7893 We then change the song to the index selected. 7894 */ 7895 _audioNavigation2.default.changeSong(_config2.default.songs[song], song); 7896 } 7897 7898 /* 7899 Check to see if the song has changed. If it has, 7900 set the active song. If it was in a playlist, the 7901 song wouldn't change here, since we already set the 7902 song when we checked for a playlist. 7903 */ 7904 if (_checks2.default.newSong(null, song)) { 7905 /* 7906 The song selected is different, so we change the 7907 song. 7908 */ 7909 _audioNavigation2.default.changeSong(_config2.default.songs[song], song); 7910 } 7911 7912 /* 7913 Plays the song 7914 */ 7915 _core2.default.play(); 7916 7917 /* 7918 Syncs the play pause elements since they are dependent upon this state 7919 of the player. 7920 */ 7921 _playPauseElements2.default.sync(); 7922 } 7923 7924 /** 7925 * Handles the song in playlist play. 7926 * 7927 * @access private 7928 * @param {string} playlist The playlist the play button belongs to. 7929 * @param {integer} song The song the play button belongs to. 7930 */ 7931 function handleSongInPlaylistPlay(playlist, song) { 7932 /* 7933 There can be multiple playlists on the page and there can be 7934 multiple songs on the page AND there can be songs in multiple 7935 playlists, so we have some checking to do. 7936 */ 7937 7938 /* 7939 Check to see if the playlist has changed. Essentially, if we are moving 7940 out of a playlist context. 7941 */ 7942 if (_checks2.default.newPlaylist(playlist)) { 7943 /* 7944 We've moved out of the playlist context, so we set the active playlist 7945 to null 7946 */ 7947 _audioNavigation2.default.setActivePlaylist(playlist); 7948 7949 /* 7950 We then change the song to the index selected. 7951 */ 7952 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[song], song); 7953 } 7954 7955 /* 7956 Check to see if the song has changed. If it has, 7957 set the active song. If it was in a playlist, the 7958 song wouldn't change here, since we already set the 7959 song when we checked for a playlist. 7960 */ 7961 if (_checks2.default.newSong(playlist, song)) { 7962 /* 7963 The song selected is different, so we change the 7964 song. 7965 */ 7966 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[song], song); 7967 } 7968 7969 /* 7970 Plays the song 7971 */ 7972 _core2.default.play(); 7973 7974 /* 7975 Now we sync all the elements to match the state of the audio. 7976 We don't need to do any checks on new songs or changed playlists 7977 in the global since it's whatever song is playing. 7978 */ 7979 _playPauseElements2.default.sync(); 7980 } 7981 7982 /* 7983 Returns the public facing elements 7984 */ 7985 return { 7986 handle: handle 7987 }; 7988}(); 7989 7990/** 7991 * Imports the AmplitudeJS Play Pause Elements 7992 * @module visual/PlayPauseElements 7993 */ 7994 7995 7996/** 7997 * Imports the AmplitudeJS Checks Utility 7998 * @module utilities/Checks 7999 */ 8000 8001 8002/** 8003 * Imports the config state utility. 8004 * @module utilities/ConfigState 8005 */ 8006exports.default = Play; 8007module.exports = exports["default"]; 8008 8009/***/ }), 8010/* 32 */ 8011/***/ (function(module, exports, __webpack_require__) { 8012 8013"use strict"; 8014 8015 8016Object.defineProperty(exports, "__esModule", { 8017 value: true 8018}); 8019 8020var _config = __webpack_require__(0); 8021 8022var _config2 = _interopRequireDefault(_config); 8023 8024var _configState = __webpack_require__(6); 8025 8026var _configState2 = _interopRequireDefault(_configState); 8027 8028var _core = __webpack_require__(1); 8029 8030var _core2 = _interopRequireDefault(_core); 8031 8032var _checks = __webpack_require__(5); 8033 8034var _checks2 = _interopRequireDefault(_checks); 8035 8036var _audioNavigation = __webpack_require__(3); 8037 8038var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 8039 8040var _playPauseElements = __webpack_require__(2); 8041 8042var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 8043 8044function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8045 8046/** 8047 * Handles all of the play pause events 8048 * @module events/PlayPause 8049 */ 8050 8051 8052/** 8053 * Imports the AmplitudeJS Audio Navigation Utility 8054 * @module utilities/AudioNavigation 8055 */ 8056 8057 8058/** 8059 * Imports the AmplitudeJS Core Methods 8060 * @module core/Core 8061 */ 8062/** 8063 * Imports the config module 8064 * @module config 8065 */ 8066var PlayPause = function () { 8067 /** 8068 * Handles an event on a play/pause button 8069 * 8070 * HANDLER FOR: class="amplitude-play-pause" 8071 * 8072 * GLOBAL: class="amplitude-play-pause" 8073 * PLAYLIST: class="amplitude-play-pause" amplitude-playlist="playlist_key" 8074 * SONG: class="amplitude-play-pause" amplitude-song-index="song_index" 8075 * SONG IN PLAYLIST: class="amplitude-play-pause" amplitude-playlist="playlist-key" amplitude-song-index="playlist_index" 8076 * 8077 * @access public 8078 */ 8079 function handle() { 8080 /* 8081 If the touch is moving, we do not want to accidentally touch the play 8082 pause element and fire an event. 8083 */ 8084 if (!_config2.default.is_touch_moving) { 8085 /* 8086 Get the playlist and song from the element. It's alright if these 8087 are null. 8088 */ 8089 var playlist = this.getAttribute("data-amplitude-playlist"); 8090 var song = this.getAttribute("data-amplitude-song-index"); 8091 8092 /* 8093 Handle a global play pause button 8094 */ 8095 if (playlist == null && song == null) { 8096 handleGlobalPlayPause(); 8097 } 8098 8099 /* 8100 Handle a playlist play pause button 8101 */ 8102 if (playlist != null && song == null) { 8103 handlePlaylistPlayPause(playlist); 8104 } 8105 8106 /* 8107 Handle a song play pause button 8108 */ 8109 if (playlist == null && song != null) { 8110 handleSongPlayPause(song); 8111 } 8112 8113 /* 8114 Handle a song in playlist play pause button 8115 */ 8116 if (playlist != null && song != null) { 8117 handleSongInPlaylistPlayPause(playlist, song); 8118 } 8119 } 8120 } 8121 8122 /** 8123 * Sets the main play pause buttons to the current state of the song. 8124 * @access private 8125 */ 8126 function handleGlobalPlayPause() { 8127 /* 8128 If the song is paused, we play the song. If the song is playing, 8129 we pause the song. 8130 */ 8131 if (_config2.default.audio.paused) { 8132 _core2.default.play(); 8133 } else { 8134 _core2.default.pause(); 8135 } 8136 8137 /* 8138 Now we sync all the elements to match the state of the audio. 8139 We don't need to do any checks on new songs or changed playlists 8140 in the global since it's whatever song is playing. 8141 */ 8142 _playPauseElements2.default.sync(); 8143 } 8144 8145 /** 8146 * Sets the playlist main play pause buttons to the current state of the song. 8147 * @access private 8148 * @param {string} playlist The playlist the main play pause button controls 8149 */ 8150 function handlePlaylistPlayPause(playlist) { 8151 /* 8152 The only thing that can change when you click a playlist 8153 play pause is the playlist. Main play pauses have no change 8154 in song, song play pauses can change playlist and song. 8155 */ 8156 if (_checks2.default.newPlaylist(playlist)) { 8157 /* 8158 If there's a new playlist, then we set the new playlist. 8159 */ 8160 _audioNavigation2.default.setActivePlaylist(playlist); 8161 8162 /* 8163 Play first song in the playlist since we just 8164 switched playlists, we start from the first song. 8165 If the user has shuffle on for the playlist, then 8166 we go from the first song in the shuffle playlist array. 8167 */ 8168 if (_config2.default.playlists[playlist].shuffle) { 8169 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].shuffle_list[0], 0, true); 8170 } else { 8171 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[0], 0); 8172 } 8173 } 8174 8175 /* 8176 If the song is paused, we play the song. If the song is playing, 8177 we pause the song. 8178 */ 8179 if (_config2.default.audio.paused) { 8180 _core2.default.play(); 8181 } else { 8182 _core2.default.pause(); 8183 } 8184 8185 /* 8186 Now we sync all the elements to match the state of the audio. 8187 We don't need to do any checks on new songs or changed playlists 8188 in the global since it's whatever song is playing. 8189 */ 8190 _playPauseElements2.default.sync(); 8191 } 8192 8193 /** 8194 * Sets the playlist main play pause buttons to the current state of the song. 8195 * @access private 8196 * @param {string} song The index of the song being played/paused 8197 */ 8198 function handleSongPlayPause(song) { 8199 /* 8200 There can be multiple playlists on the page and there can be 8201 multiple songs on the page AND there can be songs in multiple 8202 playlists, so we have some checking to do. 8203 */ 8204 8205 /* 8206 Check to see if the playlist has changed. Essentially, if we are moving 8207 out of a playlist context. 8208 */ 8209 if (_checks2.default.newPlaylist(null)) { 8210 /* 8211 We've moved out of the playlist context, so we set the active playlist 8212 to null 8213 */ 8214 _audioNavigation2.default.setActivePlaylist(null); 8215 8216 /* 8217 We then change the song to the index selected. 8218 */ 8219 _audioNavigation2.default.changeSong(_config2.default.songs[song], song, true); 8220 } 8221 8222 /* 8223 Check to see if the song has changed. If it has, 8224 set the active song. If it was in a playlist, the 8225 song wouldn't change here, since we already set the 8226 song when we checked for a playlist. 8227 */ 8228 if (_checks2.default.newSong(null, song)) { 8229 /* 8230 The song selected is different, so we change the 8231 song. 8232 */ 8233 _audioNavigation2.default.changeSong(_config2.default.songs[song], song, true); 8234 } 8235 8236 /* 8237 If the song is paused, we play the song. If the song is playing, 8238 we pause the song. 8239 */ 8240 if (_config2.default.audio.paused) { 8241 _core2.default.play(); 8242 } else { 8243 _core2.default.pause(); 8244 } 8245 8246 /* 8247 Now we sync all the elements to match the state of the audio. 8248 We don't need to do any checks on new songs or changed playlists 8249 in the global since it's whatever song is playing. 8250 */ 8251 _playPauseElements2.default.sync(); 8252 } 8253 8254 /** 8255 * Sets the song in playlist play pause buttons to the current 8256 * state of the song. 8257 * @access private 8258 * @param {string} playlist The playlist the song is a part of 8259 * @param {number} song The index of the song being played/paused 8260 */ 8261 function handleSongInPlaylistPlayPause(playlist, song) { 8262 /* 8263 There can be multiple playlists on the page and there can be 8264 multiple songs on the page AND there can be songs in multiple 8265 playlists, so we have some checking to do. 8266 */ 8267 8268 /* 8269 Check to see if the playlist has changed. Essentially, if we are moving 8270 out of a playlist context. 8271 */ 8272 if (_checks2.default.newPlaylist(playlist)) { 8273 /* 8274 We've moved out of the playlist context, so we set the active playlist 8275 to null 8276 */ 8277 _audioNavigation2.default.setActivePlaylist(playlist); 8278 8279 /* 8280 We then change the song to the index selected. 8281 */ 8282 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[song], song, true); 8283 } 8284 8285 /* 8286 Check to see if the song has changed. If it has, 8287 set the active song. If it was in a playlist, the 8288 song wouldn't change here, since we already set the 8289 song when we checked for a playlist. 8290 */ 8291 if (_checks2.default.newSong(playlist, song)) { 8292 /* 8293 The song selected is different, so we change the 8294 song. 8295 */ 8296 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[song], song, true); 8297 } 8298 8299 /* 8300 If the song is paused, we play the song. If the song is playing, 8301 we pause the song. 8302 */ 8303 if (_config2.default.audio.paused) { 8304 _core2.default.play(); 8305 } else { 8306 _core2.default.pause(); 8307 } 8308 8309 /* 8310 Now we sync all the elements to match the state of the audio. 8311 We don't need to do any checks on new songs or changed playlists 8312 in the global since it's whatever song is playing. 8313 */ 8314 _playPauseElements2.default.sync(); 8315 } 8316 8317 /** 8318 * Returns the public facing methods 8319 */ 8320 return { 8321 handle: handle 8322 }; 8323}(); 8324 8325/** 8326 * Imports the AmplitudeJS Play Pause Elements 8327 * @module visual/PlayPauseElements 8328 */ 8329 8330 8331/** 8332 * Imports the AmplitudeJS Checks Utility 8333 * @module utilities/Checks 8334 */ 8335 8336 8337/** 8338 * Import the config state utility. 8339 * @module utilities/configState 8340 */ 8341exports.default = PlayPause; 8342module.exports = exports["default"]; 8343 8344/***/ }), 8345/* 33 */ 8346/***/ (function(module, exports, __webpack_require__) { 8347 8348"use strict"; 8349 8350 8351Object.defineProperty(exports, "__esModule", { 8352 value: true 8353}); 8354 8355var _config = __webpack_require__(0); 8356 8357var _config2 = _interopRequireDefault(_config); 8358 8359var _core = __webpack_require__(1); 8360 8361var _core2 = _interopRequireDefault(_core); 8362 8363var _playbackSpeedElements = __webpack_require__(18); 8364 8365var _playbackSpeedElements2 = _interopRequireDefault(_playbackSpeedElements); 8366 8367function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8368 8369/** 8370 * AmplitudeJS Playback Speed Event Handler 8371 * 8372 * @module events/PlaybackSpeed 8373 */ 8374 8375 8376/** 8377 * Imports the Amplitude Core module 8378 * @module core/Core 8379 */ 8380var PlaybackSpeed = function () { 8381 /** 8382 * Handles an event on the playback speed button 8383 * 8384 * HANDLER FOR: class="amplitude-playback-speed" 8385 * 8386 * @access public 8387 */ 8388 function handle() { 8389 if (!_config2.default.is_touch_moving) { 8390 /* 8391 We increment the speed by .5 everytime we click 8392 the button to change the playback speed. Once we are 8393 actively playing back at 2, we start back at 1 which 8394 is normal speed. 8395 */ 8396 switch (_config2.default.playback_speed) { 8397 case 1: 8398 _core2.default.setPlaybackSpeed(1.5); 8399 break; 8400 case 1.5: 8401 _core2.default.setPlaybackSpeed(2); 8402 break; 8403 case 2: 8404 _core2.default.setPlaybackSpeed(1); 8405 break; 8406 } 8407 8408 /* 8409 Visually sync the playback speed. 8410 */ 8411 _playbackSpeedElements2.default.sync(); 8412 } 8413 } 8414 8415 /* 8416 Returns public facing methods 8417 */ 8418 return { 8419 handle: handle 8420 }; 8421}(); 8422 8423/** 8424 * Imports the Playback Speed Visual Elements 8425 * @module visual/PlaybackSpeedElements 8426 */ 8427/** 8428 * Imports the config module 8429 * @module config 8430 */ 8431exports.default = PlaybackSpeed; 8432module.exports = exports["default"]; 8433 8434/***/ }), 8435/* 34 */ 8436/***/ (function(module, exports, __webpack_require__) { 8437 8438"use strict"; 8439 8440 8441Object.defineProperty(exports, "__esModule", { 8442 value: true 8443}); 8444 8445var _config = __webpack_require__(0); 8446 8447var _config2 = _interopRequireDefault(_config); 8448 8449var _audioNavigation = __webpack_require__(3); 8450 8451var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 8452 8453var _debug = __webpack_require__(4); 8454 8455var _debug2 = _interopRequireDefault(_debug); 8456 8457function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8458 8459/** 8460 * AmplitudeJS Prev Event Handler 8461 * 8462 * @module events/Prev 8463 */ 8464 8465 8466/** 8467 * Imports the Amplitude Audio Navigation Utility 8468 * @module utilities/AudioNavigation 8469 */ 8470var Prev = function () { 8471 /** 8472 * Handles an event on the previous button 8473 * 8474 * HANDLER FOR: class="amplitude-prev" 8475 * 8476 * GLOBAL: class="amplitude-prev" 8477 * PLAYLIST: class="amplitude-prev" amplitude-playlist="playlist_key" 8478 * 8479 * @access public 8480 */ 8481 function handle() { 8482 /* 8483 We don't fire this if the user is touching the screen and it's moving. 8484 This could lead to a mis-fire 8485 */ 8486 if (!_config2.default.is_touch_moving) { 8487 /* 8488 Gets the playlist attribute from the element. 8489 */ 8490 var playlist = this.getAttribute("data-amplitude-playlist"); 8491 8492 /* 8493 If the playlist is null, we handle the global prev. 8494 */ 8495 if (playlist == null) { 8496 handleGlobalPrev(); 8497 } 8498 8499 /* 8500 If the playlist is set, we handle the playlist prev. 8501 */ 8502 if (playlist != null) { 8503 handlePlaylistPrev(playlist); 8504 } 8505 } 8506 } 8507 8508 /** 8509 * Handles an event on a global previous button. 8510 * 8511 * @access private 8512 */ 8513 function handleGlobalPrev() { 8514 /* 8515 Check to see if the current state of the player 8516 is in playlist mode or not playlist mode. If we are in playlist mode, 8517 we set prev on the playlist. 8518 */ 8519 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 8520 _audioNavigation2.default.setPrevious(); 8521 } else { 8522 _audioNavigation2.default.setPreviousPlaylist(_config2.default.active_playlist); 8523 } 8524 } 8525 8526 /** 8527 * Handles an event on a previous playlist button. 8528 * 8529 * @access private 8530 * @prop {string} playlist - The playlist we are handling the previous for. 8531 */ 8532 function handlePlaylistPrev(playlist) { 8533 /* 8534 Ensure the playlist is the same as the active playlist. To get to change 8535 the scope to a new playlist, you need to play that playlist. 8536 */ 8537 if (playlist == _config2.default.active_playlist) { 8538 _audioNavigation2.default.setPreviousPlaylist(_config2.default.active_playlist); 8539 } else { 8540 _debug2.default.writeMessage("You can not go to the previous song on a playlist that is not being played!"); 8541 } 8542 } 8543 8544 /* 8545 Returns the public facing methods. 8546 */ 8547 return { 8548 handle: handle 8549 }; 8550}(); 8551 8552/** 8553 * AmplitudeJS Debug Module 8554 * @module utilities/Debug 8555 */ 8556/** 8557 * Imports the config module 8558 * @module config 8559 */ 8560exports.default = Prev; 8561module.exports = exports["default"]; 8562 8563/***/ }), 8564/* 35 */ 8565/***/ (function(module, exports, __webpack_require__) { 8566 8567"use strict"; 8568 8569 8570Object.defineProperty(exports, "__esModule", { 8571 value: true 8572}); 8573 8574var _config = __webpack_require__(0); 8575 8576var _config2 = _interopRequireDefault(_config); 8577 8578var _bufferedProgressElements = __webpack_require__(24); 8579 8580var _bufferedProgressElements2 = _interopRequireDefault(_bufferedProgressElements); 8581 8582function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8583 8584/** 8585 * AmplitudeJS Event Handler for progress 8586 * 8587 * @module events/Progress 8588 */ 8589/** 8590 * Imports the config module 8591 * @module config 8592 */ 8593var Progress = function () { 8594 /** 8595 * As the song is buffered, we can display the buffered percentage in 8596 * a progress bar. 8597 * 8598 * HANDLER FOR: progress 8599 * 8600 * @access public 8601 */ 8602 function handle() { 8603 /* 8604 Help from: http://jsbin.com/badimipi/1/edit?html,js,output 8605 */ 8606 if (_config2.default.audio.buffered.length - 1 >= 0) { 8607 var bufferedEnd = _config2.default.audio.buffered.end(_config2.default.audio.buffered.length - 1); 8608 var duration = _config2.default.audio.duration; 8609 8610 /* 8611 Set the computed song buffered value to the config. 8612 */ 8613 _config2.default.buffered = bufferedEnd / duration * 100; 8614 } 8615 8616 /* 8617 Sync the buffered progress bars. 8618 */ 8619 _bufferedProgressElements2.default.sync(); 8620 } 8621 8622 /** 8623 * Returns the public facing methods 8624 */ 8625 return { 8626 handle: handle 8627 }; 8628}(); 8629 8630/** 8631 * Imports the BufferedProgressElements visual handler 8632 * @module visual/bufferedProgressElements.js 8633 */ 8634exports.default = Progress; 8635module.exports = exports["default"]; 8636 8637/***/ }), 8638/* 36 */ 8639/***/ (function(module, exports, __webpack_require__) { 8640 8641"use strict"; 8642 8643 8644Object.defineProperty(exports, "__esModule", { 8645 value: true 8646}); 8647 8648var _config = __webpack_require__(0); 8649 8650var _config2 = _interopRequireDefault(_config); 8651 8652var _repeater = __webpack_require__(12); 8653 8654var _repeater2 = _interopRequireDefault(_repeater); 8655 8656var _repeatElements = __webpack_require__(8); 8657 8658var _repeatElements2 = _interopRequireDefault(_repeatElements); 8659 8660function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8661 8662/** 8663 * AmplitudeJS Repeat Event Handler 8664 * 8665 * @module events/Repeat 8666 */ 8667 8668 8669/** 8670 * Imports the repeater utility module. 8671 * @module utilities/Repeater 8672 */ 8673var Repeat = function () { 8674 /** 8675 * Handles an event on the repeat button 8676 * 8677 * HANDLER FOR: class="amplitude-repeat" 8678 * 8679 * GLOBAL: class="amplitude-repeat" 8680 * PLAYLIST: class="amplitude-repeat" amplitude-playlist="playlist_key" 8681 * 8682 * @access public 8683 */ 8684 function handle() { 8685 /* 8686 We don't fire this if the user is touching the screen and it's moving. 8687 This could lead to a mis-fire 8688 */ 8689 if (!_config2.default.is_touch_moving) { 8690 /* 8691 Gets the playlist attribute from the element. 8692 */ 8693 var playlist = this.getAttribute("data-amplitude-playlist"); 8694 8695 /* 8696 If the playlist is null, we handle the global repeat. 8697 */ 8698 if (playlist == null) { 8699 handleGlobalRepeat(); 8700 } 8701 8702 /* 8703 If the playlist is set, we handle the playlist repeat. 8704 */ 8705 if (playlist != null) { 8706 handlePlaylistRepeat(playlist); 8707 } 8708 } 8709 } 8710 8711 /** 8712 * Handles an event on a global repeat button. 8713 * 8714 * @access private 8715 */ 8716 function handleGlobalRepeat() { 8717 /* 8718 Sets repeat to the opposite of what it was set to 8719 */ 8720 _repeater2.default.setRepeat(!_config2.default.repeat); 8721 8722 /* 8723 Visually sync repeat 8724 */ 8725 _repeatElements2.default.syncRepeat(); 8726 } 8727 8728 /** 8729 * Handles an event on a playlist repeat button. 8730 * 8731 * @access private 8732 * @prop {string} playlist - The playlist we are handling the repeat store. 8733 */ 8734 function handlePlaylistRepeat(playlist) { 8735 /* 8736 Sets repeat to the opposite of what it was set to for the playlist. 8737 */ 8738 _repeater2.default.setRepeatPlaylist(!_config2.default.playlists[playlist].repeat, playlist); 8739 8740 /* 8741 Visually sync playlist repeat 8742 */ 8743 _repeatElements2.default.syncRepeatPlaylist(playlist); 8744 } 8745 8746 /* 8747 Returns the public facing methods. 8748 */ 8749 return { 8750 handle: handle 8751 }; 8752}(); 8753 8754/** 8755 * Imports the visual repeat elements module 8756 * @module visual/RepeatElements 8757 */ 8758/** 8759 * Imports the config module 8760 * @module config 8761 */ 8762exports.default = Repeat; 8763module.exports = exports["default"]; 8764 8765/***/ }), 8766/* 37 */ 8767/***/ (function(module, exports, __webpack_require__) { 8768 8769"use strict"; 8770 8771 8772Object.defineProperty(exports, "__esModule", { 8773 value: true 8774}); 8775 8776var _config = __webpack_require__(0); 8777 8778var _config2 = _interopRequireDefault(_config); 8779 8780var _repeater = __webpack_require__(12); 8781 8782var _repeater2 = _interopRequireDefault(_repeater); 8783 8784var _repeatElements = __webpack_require__(8); 8785 8786var _repeatElements2 = _interopRequireDefault(_repeatElements); 8787 8788function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8789 8790/** 8791 * Handles an event on the Amplitude Repeat Song. 8792 * 8793 * @module events/RepeatSong 8794 */ 8795 8796 8797/** 8798 * Imports the repeat utility 8799 * @module utilities/Repeater 8800 */ 8801var RepeatSong = function () { 8802 /** 8803 * Handles an event on the repeat song button 8804 * 8805 * HANDLER FOR: 'amplitude-repeat-song' 8806 * 8807 * @access public 8808 */ 8809 function handle() { 8810 /* 8811 If the touch is moving, we do not want to accidentally touch the play 8812 pause element and fire an event. 8813 */ 8814 if (!_config2.default.is_touch_moving) { 8815 /* 8816 Sets repeat song to the opposite of what it was set to 8817 */ 8818 _repeater2.default.setRepeatSong(!_config2.default.repeat_song); 8819 8820 /* 8821 Visually sync repeat song 8822 */ 8823 _repeatElements2.default.syncRepeatSong(); 8824 } 8825 } 8826 8827 /** 8828 * Returns the public facing methods 8829 */ 8830 return { 8831 handle: handle 8832 }; 8833}(); 8834 8835/** 8836 * Imports the AmplitudeJS Repeat Element 8837 * @module visual/RepeatElements 8838 */ 8839/** 8840 * Imports the config module 8841 * @module config 8842 */ 8843exports.default = RepeatSong; 8844module.exports = exports["default"]; 8845 8846/***/ }), 8847/* 38 */ 8848/***/ (function(module, exports, __webpack_require__) { 8849 8850"use strict"; 8851 8852 8853Object.defineProperty(exports, "__esModule", { 8854 value: true 8855}); 8856 8857var _config = __webpack_require__(0); 8858 8859var _config2 = _interopRequireDefault(_config); 8860 8861var _shuffler = __webpack_require__(13); 8862 8863var _shuffler2 = _interopRequireDefault(_shuffler); 8864 8865var _shuffleElements = __webpack_require__(19); 8866 8867var _shuffleElements2 = _interopRequireDefault(_shuffleElements); 8868 8869function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8870 8871/** 8872 * Handles all of the shuffle events 8873 * @module events/Shuffle 8874 */ 8875 8876 8877/** 8878 * Imports the shuffler utility 8879 * @module utilities/Shuffler 8880 */ 8881var Shuffle = function () { 8882 /** 8883 * Handles an event on the shuffle button 8884 * 8885 * HANDLER FOR: class="amplitude-shuffle" 8886 * 8887 * GLOBAL: class="amplitude-shuffle" 8888 * PLAYLIST: class="amplitude-shuffle" amplitude-playlist="playlist_key" 8889 * 8890 * @access public 8891 */ 8892 function handle() { 8893 /* 8894 If the touch is moving, we do not want to accidentally touch the play 8895 pause element and fire an event. 8896 */ 8897 if (!_config2.default.is_touch_moving) { 8898 /* 8899 Get the playlist attribute 8900 */ 8901 var playlist = this.getAttribute("data-amplitude-playlist"); 8902 8903 /* 8904 Check to see if the shuffle button belongs to a playlist 8905 */ 8906 if (playlist == null) { 8907 handleGlobalShuffle(); 8908 } else { 8909 handlePlaylistShuffle(playlist); 8910 } 8911 } 8912 } 8913 8914 /** 8915 * Handles the event on the global shuffle button. 8916 */ 8917 function handleGlobalShuffle() { 8918 /* 8919 Either shuffles or removes shuffle on the global state. 8920 */ 8921 _shuffler2.default.toggleShuffle(); 8922 8923 /* 8924 Visualize the shuffle state change. 8925 */ 8926 _shuffleElements2.default.syncMain(_config2.default.shuffle_on); 8927 } 8928 8929 /** 8930 * Handles the event on the playlist shuffle button. 8931 * 8932 * @param {string} playlist - The playlist string the shuffle button belongs to. 8933 */ 8934 function handlePlaylistShuffle(playlist) { 8935 /* 8936 Either shuffles or removes shuffle on the playlist state. 8937 */ 8938 _shuffler2.default.toggleShufflePlaylist(playlist); 8939 8940 /* 8941 Visually sync the playlist shuffle statuses. 8942 */ 8943 _shuffleElements2.default.syncPlaylist(playlist); 8944 } 8945 8946 /** 8947 * Returns public facing methods 8948 */ 8949 return { 8950 handle: handle 8951 }; 8952}(); 8953 8954/** 8955 * Imports the visual shuffle elements 8956 * @module visual/ShuffleElements 8957 */ 8958/** 8959 * Imports the config module 8960 * @module config 8961 */ 8962exports.default = Shuffle; 8963module.exports = exports["default"]; 8964 8965/***/ }), 8966/* 39 */ 8967/***/ (function(module, exports, __webpack_require__) { 8968 8969"use strict"; 8970 8971 8972Object.defineProperty(exports, "__esModule", { 8973 value: true 8974}); 8975 8976var _config = __webpack_require__(0); 8977 8978var _config2 = _interopRequireDefault(_config); 8979 8980var _debug = __webpack_require__(4); 8981 8982var _debug2 = _interopRequireDefault(_debug); 8983 8984var _audioNavigation = __webpack_require__(3); 8985 8986var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 8987 8988var _checks = __webpack_require__(5); 8989 8990var _checks2 = _interopRequireDefault(_checks); 8991 8992var _core = __webpack_require__(1); 8993 8994var _core2 = _interopRequireDefault(_core); 8995 8996var _playPauseElements = __webpack_require__(2); 8997 8998var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 8999 9000function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9001 9002/** 9003 * Handles the skip to event. 9004 * 9005 * @module events/SkipTo 9006 */ 9007 9008 9009/** 9010 * Imports the AmplitudeJS Core Methods 9011 * @module core/Core 9012 */ 9013 9014 9015/** 9016 * Imports the AmplitudeJS Audio Navigation Utility 9017 * @module utilities/AudioNavigation 9018 */ 9019/** 9020 * Imports the config module 9021 * @module config 9022 */ 9023var SkipTo = function () { 9024 /** 9025 * Handles an event on a skip to button. 9026 * 9027 * HANDLER FOR: class="amplitude-skip-to" 9028 * 9029 * GLOBAL: class="amplitude-skip-to" amplitude-song-index="song_index" amplitude-location="seconds" 9030 * PLAYLIST: class="amplitude-skip-to" amplitude-playlist="playlist_key" amplitude-song-index="song_index" amplitude-location="seconds" 9031 * 9032 * @access public 9033 */ 9034 function handle() { 9035 /* 9036 If the touch is moving, we do not want to accidentally touch the play 9037 pause element and fire an event. 9038 */ 9039 if (!_config2.default.is_touch_moving) { 9040 /* 9041 Extracts the needed attributes from the element. 9042 */ 9043 var playlist = this.getAttribute("data-amplitude-playlist"); 9044 var songIndex = this.getAttribute("data-amplitude-song-index"); 9045 var location = this.getAttribute("data-amplitude-location"); 9046 9047 /* 9048 If the location is null, write a message. We can't skip to a location 9049 that is null 9050 */ 9051 if (location == null) { 9052 _debug2.default.writeMessage("You must add an 'data-amplitude-location' attribute in seconds to your 'amplitude-skip-to' element."); 9053 } 9054 9055 /* 9056 If the song index is null, write a debug message. We can't skip to a location 9057 of a null song. 9058 */ 9059 if (songIndex == null) { 9060 _debug2.default.writeMessage("You must add an 'data-amplitude-song-index' attribute to your 'amplitude-skip-to' element."); 9061 } 9062 9063 /* 9064 If the location and song index are set, continue. 9065 */ 9066 if (location != null && songIndex != null) { 9067 /* 9068 Determines if the skip to button is in the scope of a playlist. 9069 */ 9070 if (playlist == null) { 9071 handleSkipToSong(parseInt(songIndex), parseInt(location)); 9072 } else { 9073 handleSkipToPlaylist(playlist, parseInt(songIndex), parseInt(location)); 9074 } 9075 } 9076 } 9077 } 9078 9079 /** 9080 * Handles the skipping to a specific song 9081 * 9082 * @access private 9083 * @param {string} songIndex - The index of the song being skipped to 9084 * @param {number} location - The seconds location of the song in the playlist. 9085 */ 9086 function handleSkipToSong(songIndex, location) { 9087 /* 9088 Changes the song to where it's being skipped and then 9089 play the song. 9090 */ 9091 _audioNavigation2.default.changeSong(_config2.default.songs[songIndex], songIndex); 9092 _core2.default.play(); 9093 9094 /* 9095 Syncs all of the play pause buttons now that we've skipped. 9096 */ 9097 _playPauseElements2.default.syncGlobal(); 9098 _playPauseElements2.default.syncSong(); 9099 9100 /* 9101 Skip to the location in the song. 9102 */ 9103 _core2.default.skipToLocation(location); 9104 } 9105 9106 /** 9107 * Handles the skipping to a song that's in a playlist. 9108 * 9109 * @access private 9110 * @param {string} playlist - The playlist being skipped to 9111 * @param {string} songIndex - The index of the song in the playlist 9112 * @param {number} location - The seconds location of the song in the playlist. 9113 */ 9114 function handleSkipToPlaylist(playlist, songIndex, location) { 9115 /* 9116 Checks if we are skipping to a new playlist 9117 */ 9118 if (_checks2.default.newPlaylist(playlist)) { 9119 _audioNavigation2.default.setActivePlaylist(playlist); 9120 } 9121 9122 /* 9123 Changes the song to where it's being skipped and then 9124 play the song. 9125 */ 9126 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[songIndex], songIndex); 9127 _core2.default.play(); 9128 9129 /* 9130 Sync all of the play pause elements. 9131 */ 9132 _playPauseElements2.default.syncGlobal(); 9133 _playPauseElements2.default.syncPlaylist(); 9134 _playPauseElements2.default.syncSong(); 9135 9136 /* 9137 Skip to the location in the song. 9138 */ 9139 _core2.default.skipToLocation(location); 9140 } 9141 9142 /** 9143 * Return public facing methods 9144 */ 9145 return { 9146 handle: handle 9147 }; 9148}(); 9149 9150/** 9151 * Imports the AmplitudeJS play pause elements. 9152 * @module visual/PlayPauseElements 9153 */ 9154 9155 9156/** 9157 * Imports the AmplitudeJS Checks Utility 9158 * @module utilities/Checks 9159 */ 9160 9161 9162/** 9163 * Imports AmplitudeJS Debug Utility 9164 * @module utilities/debug 9165 */ 9166exports.default = SkipTo; 9167module.exports = exports["default"]; 9168 9169/***/ }), 9170/* 40 */ 9171/***/ (function(module, exports, __webpack_require__) { 9172 9173"use strict"; 9174 9175 9176Object.defineProperty(exports, "__esModule", { 9177 value: true 9178}); 9179 9180var _config = __webpack_require__(0); 9181 9182var _config2 = _interopRequireDefault(_config); 9183 9184var _time = __webpack_require__(23); 9185 9186var _time2 = _interopRequireDefault(_time); 9187 9188var _songSliderElements = __webpack_require__(14); 9189 9190var _songSliderElements2 = _interopRequireDefault(_songSliderElements); 9191 9192function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9193 9194/** 9195 * Handles the song slider to event. 9196 * 9197 * @module events/SongSlider 9198 */ 9199 9200 9201/** 9202 * Imports the time utility 9203 * @module utilities/Time 9204 */ 9205var SongSlider = function () { 9206 /** 9207 * Handles a song slider element. 9208 * 9209 * HANDLER FOR: class="amplitude-song-slider" 9210 * 9211 * GLOBAL: class="amplitude-song-slider" 9212 * PLAYLIST: class="amplitude-song-slider" amplitude-playlist="playlist_key" 9213 * SONG: class="amplitude-song-slider" amplitude-song-index="song_index" 9214 * SONG IN PLAYLIST: class="amplitude-song-slider" amplitude-playlist="playlist_key" amplitude-song-index="song_index" 9215 * 9216 * @access public 9217 */ 9218 function handle() { 9219 /* 9220 Gets the percentage of the song we will be setting the location for. 9221 */ 9222 var locationPercentage = this.value; 9223 9224 /* 9225 Computes the time in seconds for the current song. 9226 */ 9227 var computedTime = _config2.default.audio.duration * (locationPercentage / 100); 9228 9229 /* 9230 Gets the attributes for playlist and index for the element. 9231 */ 9232 var playlist = this.getAttribute("data-amplitude-playlist"); 9233 var song = this.getAttribute("data-amplitude-song-index"); 9234 9235 /* 9236 If no playlist or song is defined, then it's a global song slider. 9237 */ 9238 if (playlist == null && song == null) { 9239 handleGlobalSongSlider(computedTime, locationPercentage); 9240 } 9241 9242 /* 9243 If a playlist but no song is defined, then it's playlist slider. 9244 */ 9245 if (playlist != null && song == null) { 9246 handlePlaylistSongSlider(computedTime, locationPercentage, playlist); 9247 } 9248 9249 /* 9250 If no playlist but a song is defined, then it's a song slider. 9251 */ 9252 if (playlist == null && song != null) { 9253 handleSongSongSlider(computedTime, locationPercentage, song); 9254 } 9255 9256 /* 9257 If playlist and song are defined then it's a song in a playlist 9258 slider. 9259 */ 9260 if (playlist != null && song != null) { 9261 handleSongInPlaylistSongSlider(computedTime, locationPercentage, playlist, song); 9262 } 9263 } 9264 9265 /** 9266 * Handles a change on a global audio slider 9267 * 9268 * @access private 9269 * @param {integer} computedTime - The time we will set the audio to. 9270 * @param {float} locationPercentage - The percent through the song. 9271 */ 9272 function handleGlobalSongSlider(computedTime, locationPercentage) { 9273 /* 9274 If the active song is not live, set the current time and adjust the slider. 9275 */ 9276 if (!_config2.default.active_metadata.live) { 9277 _time2.default.setCurrentTime(computedTime); 9278 9279 /* 9280 Sync song slider elements. 9281 */ 9282 _songSliderElements2.default.sync(locationPercentage, _config2.default.active_playlist, _config2.default.active_index); 9283 } 9284 } 9285 9286 /** 9287 * Handles a change on a playlist audio slider 9288 * 9289 * @access private 9290 * @param {integer} computedTime - The time we will set the audio to. 9291 * @param {float} locationPercentage - The percent through the song. 9292 * @param {string} playlist = The playlist the song slider belongs to. 9293 */ 9294 function handlePlaylistSongSlider(computedTime, locationPercentage, playlist) { 9295 /* 9296 We don't want to song slide a playlist that's not the 9297 active placylist. 9298 */ 9299 if (_config2.default.active_playlist == playlist) { 9300 /* 9301 If the active song is not live, set the current time 9302 */ 9303 if (!_config2.default.active_metadata.live) { 9304 _time2.default.setCurrentTime(computedTime); 9305 9306 /* 9307 Sync song slider elements. 9308 */ 9309 _songSliderElements2.default.sync(locationPercentage, playlist, _config2.default.active_index); 9310 } 9311 } 9312 } 9313 9314 /** 9315 * Handles a change on a song audio slider 9316 * 9317 * @access private 9318 * @param {integer} computedTime - The time we will set the audio to. 9319 * @param {float} locationPercentage - The percent through the song. 9320 * @param {integer} songIndex = The song being navigated. 9321 */ 9322 function handleSongSongSlider(computedTime, locationPercentage, songIndex) { 9323 /* 9324 We only want to move the slider if the active song is the 9325 same as the song being selected. 9326 */ 9327 if (_config2.default.active_index == songIndex && _config2.default.active_playlist == null) { 9328 /* 9329 If the active song is not live, set the current time 9330 */ 9331 if (!_config2.default.active_metadata.live) { 9332 _time2.default.setCurrentTime(computedTime); 9333 9334 /* 9335 Sync song slider elements. 9336 */ 9337 _songSliderElements2.default.sync(locationPercentage, _config2.default.active_playlist, songIndex); 9338 } 9339 } 9340 } 9341 9342 /** 9343 * Handles a change on a song audio slider 9344 * 9345 * @access private 9346 * @param {integer} computedTime - The time we will set the audio to. 9347 * @param {float} locationPercentage - The percent through the song. 9348 * @param {integer} playlist = The playlist the song belongs to. 9349 * @param {integer} songIndex = The song being navigated. 9350 */ 9351 function handleSongInPlaylistSongSlider(computedTime, locationPercentage, playlist, songIndex) { 9352 /* 9353 We only want to move the slider if the active song is the 9354 same as the song being selected and the active playlist is the same 9355 as the playlist selected. 9356 */ 9357 if (_config2.default.playlists[playlist].active_index == songIndex && _config2.default.active_playlist == playlist) { 9358 /* 9359 If the active song is not live, set the current time 9360 */ 9361 if (!_config2.default.active_metadata.live) { 9362 _time2.default.setCurrentTime(computedTime); 9363 9364 /* 9365 Sync song slider elements. 9366 */ 9367 _songSliderElements2.default.sync(locationPercentage, playlist, songIndex); 9368 } 9369 } 9370 } 9371 9372 /* 9373 Return public facing methods 9374 */ 9375 return { 9376 handle: handle 9377 }; 9378}(); 9379 9380/** 9381 * Imports the song slider elements. 9382 * @module visual/SongSliderElements 9383 */ 9384/** 9385 * Imports the config module 9386 * @module config 9387 */ 9388exports.default = SongSlider; 9389module.exports = exports["default"]; 9390 9391/***/ }), 9392/* 41 */ 9393/***/ (function(module, exports, __webpack_require__) { 9394 9395"use strict"; 9396 9397 9398Object.defineProperty(exports, "__esModule", { 9399 value: true 9400}); 9401 9402var _config = __webpack_require__(0); 9403 9404var _config2 = _interopRequireDefault(_config); 9405 9406var _configState = __webpack_require__(6); 9407 9408var _configState2 = _interopRequireDefault(_configState); 9409 9410var _playPauseElements = __webpack_require__(2); 9411 9412var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 9413 9414var _core = __webpack_require__(1); 9415 9416var _core2 = _interopRequireDefault(_core); 9417 9418function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9419 9420/** 9421 * Handles all of the stop events 9422 * @module events/Stop 9423 */ 9424 9425 9426/** 9427 * Imports the AmplitudeJS Play Pause Elements 9428 * @module visual/PlayPauseElements 9429 */ 9430/** 9431 * Imports the config module 9432 * @module config 9433 */ 9434var Stop = function () { 9435 /** 9436 * Handles an event on a stop element. 9437 * 9438 * HANDLER FOR: class="amplitude-stop" 9439 * 9440 * @access public 9441 */ 9442 function handle() { 9443 /* 9444 If touch is not moving, we run. We don't want to accidentally press 9445 stop if touch is moving. 9446 */ 9447 if (!_config2.default.is_touch_moving) { 9448 /* 9449 Sets all of the play/pause buttons to pause 9450 */ 9451 _playPauseElements2.default.syncToPause(); 9452 9453 /* 9454 Stops the active song. 9455 */ 9456 _core2.default.stop(); 9457 } 9458 } 9459 9460 /** 9461 * Returns public facing methods 9462 */ 9463 return { 9464 handle: handle 9465 }; 9466}(); 9467 9468/** 9469 * Imports the AmplitudeJS Core Methods 9470 * @module core/Core 9471 */ 9472 9473 9474/** 9475 * Imports the config state module. 9476 * @module utilities/configState 9477 */ 9478exports.default = Stop; 9479module.exports = exports["default"]; 9480 9481/***/ }), 9482/* 42 */ 9483/***/ (function(module, exports, __webpack_require__) { 9484 9485"use strict"; 9486 9487 9488Object.defineProperty(exports, "__esModule", { 9489 value: true 9490}); 9491 9492var _config = __webpack_require__(0); 9493 9494var _config2 = _interopRequireDefault(_config); 9495 9496var _bufferedProgressElements = __webpack_require__(24); 9497 9498var _bufferedProgressElements2 = _interopRequireDefault(_bufferedProgressElements); 9499 9500var _timeElements = __webpack_require__(15); 9501 9502var _timeElements2 = _interopRequireDefault(_timeElements); 9503 9504var _songSliderElements = __webpack_require__(14); 9505 9506var _songSliderElements2 = _interopRequireDefault(_songSliderElements); 9507 9508var _songPlayedProgressElements = __webpack_require__(20); 9509 9510var _songPlayedProgressElements2 = _interopRequireDefault(_songPlayedProgressElements); 9511 9512var _time = __webpack_require__(23); 9513 9514var _time2 = _interopRequireDefault(_time); 9515 9516var _callbacks = __webpack_require__(9); 9517 9518var _callbacks2 = _interopRequireDefault(_callbacks); 9519 9520function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9521 9522/** 9523 * AmplitudeJS Event Handler for Time Update 9524 * 9525 * @module events/TimeUpdate 9526 */ 9527 9528 9529/** 9530 * Imports the Time utility class 9531 * @module utilities/Time 9532 */ 9533 9534 9535/** 9536 * Imports the Song Slider Elements visual class. 9537 * @module visual/songSliderElements 9538 */ 9539 9540 9541/** 9542 * Imports the Buffered Progress Elements visual class 9543 * @module visual/bufferedProgressElements 9544 */ 9545var TimeUpdate = function () { 9546 /** 9547 * When the time updates on the active song, we sync the current time displays 9548 * 9549 * HANDLER FOR: timeupdate 9550 * 9551 * @access public 9552 */ 9553 function handle() { 9554 /* 9555 Computes the buffered time. 9556 */ 9557 computeBufferedTime(); 9558 9559 /* 9560 Sync the buffered progress elements. 9561 */ 9562 _bufferedProgressElements2.default.sync(); 9563 9564 /* 9565 Updates the current time information. 9566 */ 9567 updateTimeInformation(); 9568 9569 /* 9570 Run time callbacks 9571 */ 9572 runTimeCallbacks(); 9573 } 9574 9575 /** 9576 * Computes the buffered time 9577 */ 9578 function computeBufferedTime() { 9579 /* 9580 Help from: http://jsbin.com/badimipi/1/edit?html,js,output 9581 */ 9582 if (_config2.default.audio.buffered.length - 1 >= 0) { 9583 var bufferedEnd = _config2.default.audio.buffered.end(_config2.default.audio.buffered.length - 1); 9584 var duration = _config2.default.audio.duration; 9585 9586 _config2.default.buffered = bufferedEnd / duration * 100; 9587 } 9588 } 9589 9590 /** 9591 * Updates the current time information. 9592 * @access private 9593 */ 9594 function updateTimeInformation() { 9595 /* 9596 If the current song is not live, then 9597 we can update the time information. Otherwise the 9598 current time updates wouldn't mean much since the time 9599 is infinite. 9600 */ 9601 if (!_config2.default.active_metadata.live) { 9602 /* 9603 Compute the current time 9604 */ 9605 var currentTime = _time2.default.computeCurrentTimes(); 9606 9607 /* 9608 Compute the song completion percentage 9609 */ 9610 var songCompletionPercentage = _time2.default.computeSongCompletionPercentage(); 9611 9612 /* 9613 Computes the song duration 9614 */ 9615 var songDuration = _time2.default.computeSongDuration(); 9616 9617 /* 9618 Sync the current time elements with the current 9619 location of the song and the song duration elements with 9620 the duration of the song. 9621 */ 9622 _timeElements2.default.syncCurrentTimes(currentTime); 9623 9624 /* 9625 Sync the song slider elements. 9626 */ 9627 _songSliderElements2.default.sync(songCompletionPercentage, _config2.default.active_playlist, _config2.default.active_index); 9628 9629 /* 9630 Sync the song played progress elements. 9631 */ 9632 _songPlayedProgressElements2.default.sync(songCompletionPercentage); 9633 9634 /* 9635 Sync the duration time elements. 9636 */ 9637 _timeElements2.default.syncDurationTimes(currentTime, songDuration); 9638 } 9639 } 9640 9641 /** 9642 * Runs a callback at a certain time in the song. 9643 */ 9644 function runTimeCallbacks() { 9645 /* 9646 Gets the current seconds into the song. 9647 */ 9648 var currentSeconds = Math.floor(_config2.default.audio.currentTime); 9649 9650 /* 9651 Checks to see if there is a callback at the certain seconds into the song. 9652 */ 9653 if (_config2.default.active_metadata.time_callbacks != undefined && _config2.default.active_metadata.time_callbacks[currentSeconds] != undefined) { 9654 /* 9655 Checks to see if the callback has been run. Since the time updates more than 9656 one second, we don't want the callback to run X times. 9657 */ 9658 if (!_config2.default.active_metadata.time_callbacks[currentSeconds].run) { 9659 _config2.default.active_metadata.time_callbacks[currentSeconds].run = true; 9660 _config2.default.active_metadata.time_callbacks[currentSeconds](); 9661 } 9662 } else { 9663 /* 9664 Iterate over all of the callbacks for a song. If the song has one, we flag 9665 the run as false. This occurs because we have passed the active second for 9666 the callback, so we flag it as not run. It will either run again if the user 9667 seeks back or not run in the future. 9668 */ 9669 for (var seconds in _config2.default.active_metadata.time_callbacks) { 9670 if (_config2.default.active_metadata.time_callbacks.hasOwnProperty(seconds)) { 9671 _config2.default.active_metadata.time_callbacks[seconds].run = false; 9672 } 9673 } 9674 } 9675 } 9676 /** 9677 * Returns public functions 9678 */ 9679 return { 9680 handle: handle 9681 }; 9682}(); 9683 9684/** 9685 * Imports the Callback utility class 9686 * @module utilities/Callbacks 9687 */ 9688 9689 9690/** 9691 * Imports the Song Played Progress Elements visual class. 9692 * @module visual/songPlayedProgressElements 9693 */ 9694 9695 9696/** 9697 * Imports the Time Elements visual class. 9698 * @module visual/timeElements 9699 */ 9700/** 9701 * Imports the config module 9702 * @module config 9703 */ 9704exports.default = TimeUpdate; 9705module.exports = exports["default"]; 9706 9707/***/ }), 9708/* 43 */ 9709/***/ (function(module, exports, __webpack_require__) { 9710 9711"use strict"; 9712 9713 9714Object.defineProperty(exports, "__esModule", { 9715 value: true 9716}); 9717 9718var _config = __webpack_require__(0); 9719 9720var _config2 = _interopRequireDefault(_config); 9721 9722var _core = __webpack_require__(1); 9723 9724var _core2 = _interopRequireDefault(_core); 9725 9726var _muteElements = __webpack_require__(10); 9727 9728var _muteElements2 = _interopRequireDefault(_muteElements); 9729 9730var _volumeSliderElements = __webpack_require__(11); 9731 9732var _volumeSliderElements2 = _interopRequireDefault(_volumeSliderElements); 9733 9734function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9735 9736/** 9737 * Handles all events for a volume down event. 9738 * @module events/VolumeDown 9739 */ 9740 9741 9742/** 9743 * Imports the AmplitudeJS Visual Mute Elements 9744 * @module visual/MuteElements 9745 */ 9746/** 9747 * Imports the config to use the values 9748 */ 9749var VolumeDown = function () { 9750 /** 9751 * Handles a click on a volume down element. 9752 * 9753 * HANDLER FOR: class="amplitude-volume-down" 9754 * 9755 * @access public 9756 */ 9757 function handle() { 9758 /* 9759 We don't fire this if the user is touching the screen and it's moving. 9760 This could lead to a mis-fire 9761 */ 9762 if (!_config2.default.is_touch_moving) { 9763 /* 9764 The volume range is from 0 to 1 for an audio element. We make this 9765 a base of 100 for ease of working with. 9766 If the new value is less than 100, we use the new calculated 9767 value which gets converted to the proper unit for the audio element. 9768 If the new value is greater than 100, we set the volume to 1 which 9769 is the max for the audio element. 9770 */ 9771 var volume = null; 9772 9773 if (_config2.default.volume - _config2.default.volume_increment > 0) { 9774 volume = _config2.default.volume - _config2.default.volume_increment; 9775 } else { 9776 volume = 0; 9777 } 9778 9779 /* 9780 Calls the core function to set the volume to the computed value 9781 based on the user's intent. 9782 */ 9783 _core2.default.setVolume(volume); 9784 9785 /* 9786 Sync Mute Elements. 9787 */ 9788 _muteElements2.default.setMuted(_config2.default.volume == 0 ? true : false); 9789 9790 /* 9791 Sync Volume Slider Elements 9792 */ 9793 _volumeSliderElements2.default.sync(); 9794 } 9795 } 9796 9797 /** 9798 * Returns the public facing methods 9799 */ 9800 return { 9801 handle: handle 9802 }; 9803}(); 9804 9805/** 9806 * Imports the AmplitudeJS Visual Volume Slider Elements 9807 * @module visual/VolumeSliderElements 9808 */ 9809 9810 9811/** 9812 * Imports the AmplitudeJS Core Methods 9813 * @module core/core 9814 */ 9815exports.default = VolumeDown; 9816module.exports = exports["default"]; 9817 9818/***/ }), 9819/* 44 */ 9820/***/ (function(module, exports, __webpack_require__) { 9821 9822"use strict"; 9823 9824 9825Object.defineProperty(exports, "__esModule", { 9826 value: true 9827}); 9828 9829var _config = __webpack_require__(0); 9830 9831var _config2 = _interopRequireDefault(_config); 9832 9833var _core = __webpack_require__(1); 9834 9835var _core2 = _interopRequireDefault(_core); 9836 9837var _muteElements = __webpack_require__(10); 9838 9839var _muteElements2 = _interopRequireDefault(_muteElements); 9840 9841var _volumeSliderElements = __webpack_require__(11); 9842 9843var _volumeSliderElements2 = _interopRequireDefault(_volumeSliderElements); 9844 9845function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9846 9847/** 9848 * Handles all events for a volume up event. 9849 * @module events/VolumeSlider 9850 */ 9851 9852 9853/** 9854 * Imports the AmplitudeJS Visual Mute Elements 9855 * @module visual/MuteElements 9856 */ 9857/** 9858 * Imports the config to use the values 9859 */ 9860var VolumeSlider = function () { 9861 /** 9862 * Handles a change on the volume slider 9863 * 9864 * HANDLER FOR: class="amplitude-volume-slider" 9865 * 9866 * @access public 9867 */ 9868 function handle() { 9869 /* 9870 Calls the core function to set the volume to the computed value 9871 based on the user's intent. 9872 */ 9873 _core2.default.setVolume(this.value); 9874 9875 /* 9876 Sync Mute Elements. 9877 */ 9878 _muteElements2.default.setMuted(_config2.default.volume == 0 ? true : false); 9879 9880 /* 9881 Sync the volume slider locations 9882 */ 9883 _volumeSliderElements2.default.sync(); 9884 } 9885 9886 /** 9887 * Returns the public facing methods 9888 */ 9889 return { 9890 handle: handle 9891 }; 9892}(); 9893 9894/** 9895 * Imports the AmplitudeJS Visual Volume Slider Elements 9896 * @module visual/VolumeSliderElements 9897 */ 9898 9899 9900/** 9901 * Imports the AmplitudeJS Core Methods 9902 * @module core/core 9903 */ 9904exports.default = VolumeSlider; 9905module.exports = exports["default"]; 9906 9907/***/ }), 9908/* 45 */ 9909/***/ (function(module, exports, __webpack_require__) { 9910 9911"use strict"; 9912 9913 9914Object.defineProperty(exports, "__esModule", { 9915 value: true 9916}); 9917 9918var _config = __webpack_require__(0); 9919 9920var _config2 = _interopRequireDefault(_config); 9921 9922var _core = __webpack_require__(1); 9923 9924var _core2 = _interopRequireDefault(_core); 9925 9926var _muteElements = __webpack_require__(10); 9927 9928var _muteElements2 = _interopRequireDefault(_muteElements); 9929 9930var _volumeSliderElements = __webpack_require__(11); 9931 9932var _volumeSliderElements2 = _interopRequireDefault(_volumeSliderElements); 9933 9934function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9935 9936/** 9937 * Handles all events for a volume up event. 9938 * @module events/VolumeUp 9939 */ 9940 9941 9942/** 9943 * Imports the AmplitudeJS Visual Mute Elements 9944 * @module visual/MuteElements 9945 */ 9946/** 9947 * Imports the config to use the values 9948 */ 9949var VolumeUp = function () { 9950 /** 9951 * Handles a click on a volume up element. 9952 * 9953 * HANDLER FOR: class="amplitude-volume-up" 9954 * 9955 * @access public 9956 */ 9957 function handle() { 9958 /* 9959 We don't fire this if the user is touching the screen and it's moving. 9960 This could lead to a mis-fire 9961 */ 9962 if (!_config2.default.is_touch_moving) { 9963 /* 9964 The volume range is from 0 to 1 for an audio element. We make this 9965 a base of 100 for ease of working with. 9966 If the new value is less than 100, we use the new calculated 9967 value which gets converted to the proper unit for the audio element. 9968 If the new value is greater than 100, we set the volume to 1 which 9969 is the max for the audio element. 9970 */ 9971 var volume = null; 9972 9973 if (_config2.default.volume + _config2.default.volume_increment <= 100) { 9974 volume = _config2.default.volume + _config2.default.volume_increment; 9975 } else { 9976 volume = 100; 9977 } 9978 9979 /* 9980 Calls the core function to set the volume to the computed value 9981 based on the user's intent. 9982 */ 9983 _core2.default.setVolume(volume); 9984 9985 /* 9986 Sync Mute Elements. 9987 */ 9988 _muteElements2.default.setMuted(_config2.default.volume == 0 ? true : false); 9989 9990 /* 9991 Sync Volume Slider Elements 9992 */ 9993 _volumeSliderElements2.default.sync(); 9994 } 9995 } 9996 9997 /** 9998 * Returns the public facing methods 9999 */ 10000 return { 10001 handle: handle 10002 }; 10003}(); 10004 10005/** 10006 * Imports the AmplitudeJS Visual Volume Slider Elements 10007 * @module visual/VolumeSliderElements 10008 */ 10009 10010 10011/** 10012 * Imports the AmplitudeJS Core Methods 10013 * @module core/core 10014 */ 10015exports.default = VolumeUp; 10016module.exports = exports["default"]; 10017 10018/***/ }), 10019/* 46 */ 10020/***/ (function(module, exports, __webpack_require__) { 10021 10022"use strict"; 10023 10024 10025Object.defineProperty(exports, "__esModule", { 10026 value: true 10027}); 10028 10029var _config = __webpack_require__(0); 10030 10031var _config2 = _interopRequireDefault(_config); 10032 10033function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10034 10035/** 10036 * AmplitudeJS FX Module. Helps with configuring and setting up visualizations 10037 * and any other features of the Web Audio API that Amplitude takes advantage 10038 * of. 10039 * 10040 * @module fx/FX 10041 */ 10042var Fx = function () { 10043 /** 10044 * Configures the Web Audio API to work with AmplitudeJS 10045 */ 10046 function configureWebAudioAPI() { 10047 /* 10048 Gets the context for the browser. If this is null, the Web Audio 10049 API is unavailable. 10050 */ 10051 var browserContext = window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.oAudioContext || window.msAudioContext; 10052 10053 /* 10054 If we have a context, the Web Audio API is available and we can continue, 10055 otherwise, we alert the user if they have debug turned on. 10056 */ 10057 if (browserContext) { 10058 /* 10059 Web Audio API is available, set the context in our config. 10060 */ 10061 _config2.default.context = new browserContext(); 10062 10063 /* 10064 Create an analyzer that we will use in the context. 10065 */ 10066 _config2.default.analyser = _config2.default.context.createAnalyser(); 10067 10068 /* 10069 Set cross origin to anonymous so we have a better chance of being able 10070 to use the power of the Web Audio API. 10071 */ 10072 _config2.default.audio.crossOrigin = "anonymous"; 10073 10074 /* 10075 Bind the source to the Javascript Audio Element. 10076 */ 10077 _config2.default.source = _config2.default.context.createMediaElementSource(_config2.default.audio); 10078 10079 /* 10080 Connect the analyser to the source 10081 */ 10082 _config2.default.source.connect(_config2.default.analyser); 10083 10084 /* 10085 Connect the context destination to the analyser. 10086 */ 10087 _config2.default.analyser.connect(_config2.default.context.destination); 10088 } else { 10089 AmplitudeHelpers.writeDebugMessage("Web Audio API is unavailable! We will set any of your visualizations with your back up definition!"); 10090 } 10091 } 10092 10093 /** 10094 * Determines if the web audio API is available or not. 10095 */ 10096 function webAudioAPIAvailable() { 10097 /* 10098 Gets the context for the browser. If this is null, the Web Audio 10099 API is unavailable. 10100 */ 10101 var browserContext = window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.oAudioContext || window.msAudioContext; 10102 _config2.default.web_audio_api_available = false; 10103 10104 /* 10105 Determines if the Web Audio API is available or not. 10106 */ 10107 if (browserContext) { 10108 /* 10109 Set the flag in the config that the Web Audio API is available 10110 */ 10111 _config2.default.web_audio_api_available = true; 10112 return true; 10113 } else { 10114 /* 10115 Set the flag in the config that the Web Audio API is not available 10116 */ 10117 _config2.default.web_audio_api_available = false; 10118 return false; 10119 } 10120 } 10121 10122 /** 10123 * Determines if the user is using any of the web audio API features. 10124 */ 10125 function determineUsingAnyFX() { 10126 var waveforms = document.querySelectorAll(".amplitude-wave-form"); 10127 var visualizationElements = document.querySelectorAll(".amplitude-visualization"); 10128 10129 if (waveforms.length > 0 || visualizationElements.length > 0) { 10130 return true; 10131 } else { 10132 return false; 10133 } 10134 } 10135 10136 /* 10137 Returns the publicly accessible methods 10138 */ 10139 return { 10140 configureWebAudioAPI: configureWebAudioAPI, 10141 webAudioAPIAvailable: webAudioAPIAvailable, 10142 determineUsingAnyFX: determineUsingAnyFX 10143 }; 10144}(); /** 10145 * Imports the config module 10146 * @module config 10147 */ 10148exports.default = Fx; 10149module.exports = exports["default"]; 10150 10151/***/ }), 10152/* 47 */ 10153/***/ (function(module, exports, __webpack_require__) { 10154 10155"use strict"; 10156 10157 10158Object.defineProperty(exports, "__esModule", { 10159 value: true 10160}); 10161 10162var _init = __webpack_require__(21); 10163 10164var _init2 = _interopRequireDefault(_init); 10165 10166var _config = __webpack_require__(0); 10167 10168var _config2 = _interopRequireDefault(_config); 10169 10170var _core = __webpack_require__(1); 10171 10172var _core2 = _interopRequireDefault(_core); 10173 10174var _shuffler = __webpack_require__(13); 10175 10176var _shuffler2 = _interopRequireDefault(_shuffler); 10177 10178var _configState = __webpack_require__(6); 10179 10180var _configState2 = _interopRequireDefault(_configState); 10181 10182var _audioNavigation = __webpack_require__(3); 10183 10184var _audioNavigation2 = _interopRequireDefault(_audioNavigation); 10185 10186var _repeater = __webpack_require__(12); 10187 10188var _repeater2 = _interopRequireDefault(_repeater); 10189 10190var _checks = __webpack_require__(5); 10191 10192var _checks2 = _interopRequireDefault(_checks); 10193 10194var _visualizations = __webpack_require__(16); 10195 10196var _visualizations2 = _interopRequireDefault(_visualizations); 10197 10198var _shuffleElements = __webpack_require__(19); 10199 10200var _shuffleElements2 = _interopRequireDefault(_shuffleElements); 10201 10202var _repeatElements = __webpack_require__(8); 10203 10204var _repeatElements2 = _interopRequireDefault(_repeatElements); 10205 10206var _songSliderElements = __webpack_require__(14); 10207 10208var _songSliderElements2 = _interopRequireDefault(_songSliderElements); 10209 10210var _songPlayedProgressElements = __webpack_require__(20); 10211 10212var _songPlayedProgressElements2 = _interopRequireDefault(_songPlayedProgressElements); 10213 10214var _timeElements = __webpack_require__(15); 10215 10216var _timeElements2 = _interopRequireDefault(_timeElements); 10217 10218var _playPauseElements = __webpack_require__(2); 10219 10220var _playPauseElements2 = _interopRequireDefault(_playPauseElements); 10221 10222var _metaDataElements = __webpack_require__(7); 10223 10224var _metaDataElements2 = _interopRequireDefault(_metaDataElements); 10225 10226var _playbackSpeedElements = __webpack_require__(18); 10227 10228var _playbackSpeedElements2 = _interopRequireDefault(_playbackSpeedElements); 10229 10230var _debug = __webpack_require__(4); 10231 10232var _debug2 = _interopRequireDefault(_debug); 10233 10234var _soundcloud = __webpack_require__(17); 10235 10236var _soundcloud2 = _interopRequireDefault(_soundcloud); 10237 10238function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10239 10240/** 10241 * Amplitude should just be an interface to the public functions. 10242 * Everything else should be handled by other objects 10243 * 10244 * @module Amplitude 10245 */ 10246 10247 10248/** 10249 * Meta Data Elements 10250 * @module visual/MetaDataElements 10251 */ 10252 10253 10254/** 10255 * Time Elements 10256 * @module visual/TimeElements 10257 */ 10258 10259 10260/** 10261 * Song Slider Elements 10262 * @module visual/SongSliderElements 10263 */ 10264 10265 10266/**************************************************** 10267 * Elements 10268 ****************************************************/ 10269/** 10270 * Visual Shuffle Elements 10271 * @module visual/ShuffleElements 10272 */ 10273 10274 10275/** 10276 * Imports the checks 10277 * @module utilities/Checks 10278 */ 10279 10280 10281/** 10282 * Imports the audio navigation 10283 * @module utilities/AudioNavigation 10284 */ 10285 10286 10287/**************************************************** 10288 * Utilities 10289 ****************************************************/ 10290/** 10291 * Shuffler Module 10292 * @module utilities/Shuffler 10293 */ 10294 10295 10296/**************************************************** 10297 * Config 10298 ****************************************************/ 10299/** 10300 * Imports the config module 10301 * @module config 10302 */ 10303var Amplitude = function () { 10304 /** 10305 * The main init function. The user will call this through 10306 * Amplitude.init({}) and pass in their settings. 10307 * 10308 * Public Accessor: Amplitude.init( user_config_json ); 10309 * 10310 * @access public 10311 * @param {object} userConfig - A JSON object of user defined values that helps configure and initialize AmplitudeJS. 10312 */ 10313 function init(userConfig) { 10314 _init2.default.initialize(userConfig); 10315 } 10316 10317 /** 10318 * Returns the current config for AmplitudeJS 10319 */ 10320 function getConfig() { 10321 return _config2.default; 10322 } 10323 10324 /** 10325 * Binds new elements that were added to the page. 10326 * 10327 * Public Accessor: Amplitude.bindNewElements() 10328 * 10329 * @access public 10330 */ 10331 function bindNewElements() { 10332 _init2.default.rebindDisplay(); 10333 } 10334 10335 /** 10336 * Returns the active playlist. 10337 * 10338 * Public Accessor: Amplitude.getActivePlaylist() 10339 * 10340 * @access public 10341 */ 10342 function getActivePlaylist() { 10343 return _config2.default.active_playlist; 10344 } 10345 10346 /** 10347 * Returns the current playback speed. 10348 * 10349 * Public Accessor: Amplitude.getPlaybackSpeed() 10350 * 10351 * @access public 10352 */ 10353 function getPlaybackSpeed() { 10354 return _config2.default.playback_speed; 10355 } 10356 10357 /** 10358 * Sets the playback speed 10359 * 10360 * Public Accessor: Amplitude.setPlaybackSpeed( speed ) 10361 * 10362 * @access public 10363 */ 10364 function setPlaybackSpeed(speed) { 10365 /* 10366 Increments are set in .5 We only accept values 10367 1, 1.5, 2 10368 1 -> Regular Speed 10369 1.5 -> 50% faster 10370 2 -> Twice as fast 10371 */ 10372 _core2.default.setPlaybackSpeed(speed); 10373 10374 /* 10375 Visually sync the playback speed. 10376 */ 10377 _playbackSpeedElements2.default.sync(); 10378 } 10379 10380 /** 10381 * Gets the repeat state of the player. 10382 * 10383 * Public Accessor: Amplitude.getRepeat() 10384 * 10385 * @access public 10386 */ 10387 function getRepeat() { 10388 return _config2.default.repeat; 10389 } 10390 10391 /** 10392 * Gets the repeat state for a playlist 10393 * 10394 * Public Accessor: Amplitude.getRepeatPlaylist() 10395 * 10396 * @access public 10397 */ 10398 function getRepeatPlaylist(playlistKey) { 10399 return _config2.default.playlists[playlistKey].repeat; 10400 } 10401 10402 /** 10403 * Returns the shuffle state of the player. 10404 * 10405 * Public Accessor: Amplitude.getShuffle() 10406 * 10407 * @access public 10408 */ 10409 function getShuffle() { 10410 return _config2.default.shuffle_on; 10411 } 10412 10413 /** 10414 * Returns the shuffle state of the playlist. 10415 * 10416 * Public Accessor: Amplitude.getShufflePlaylist( playlist ) 10417 * 10418 * @access public 10419 * @param {string} playlist - The key representing the playlist ID to see if it's shuffled or not. 10420 */ 10421 function getShufflePlaylist(playlist) { 10422 return _config2.default.playlists[playlist].shuffle; 10423 } 10424 10425 /** 10426 * Sets the shuffle state for the player. 10427 * 10428 * Public Accessor: Amplitude.setShuffle() 10429 * 10430 * @param {boolean} shuffle - True when we are shuffling the songs, false when we turn off shuffle. 10431 * 10432 * @access public 10433 */ 10434 function setShuffle(shuffle) { 10435 _shuffler2.default.setShuffle(shuffle); 10436 10437 _shuffleElements2.default.syncMain(); 10438 } 10439 10440 /** 10441 * Sets the shuffle state for the playlist 10442 * 10443 * Public Accessor: Amplitude.setShufflePlaylist( playlist ) 10444 * 10445 * @access public 10446 * @param {string} playlist - The key representing the playlist ID to to shuffle the playlist. 10447 * @param {boolean} shuffle - True when we are shuffling the playlist, false when we turn off shuffle. 10448 */ 10449 function setShufflePlaylist(playlist, shuffle) { 10450 _shuffler2.default.setShufflePlaylist(playlist, shuffle); 10451 10452 _shuffleElements2.default.syncMain(); 10453 _shuffleElements2.default.syncPlaylist(playlist); 10454 } 10455 10456 /** 10457 * Sets the repeat state for the player. 10458 * 10459 * Public Accessor: Amplitude.setRepeat() 10460 * 10461 * @access public 10462 * @param {boolean} repeatState - The state you want the repeat song to be in. 10463 */ 10464 function setRepeat(repeatState) { 10465 _repeater2.default.setRepeat(repeatState); 10466 _repeatElements2.default.syncRepeat(); 10467 } 10468 10469 /** 10470 * Sets the repeat state for a playlist. 10471 * 10472 * Public Accessor: Amplitude.setRepeatPlaylist( playlistKey ) 10473 * 10474 * @access public 10475 * @param {string} playlist - The key representing the playlist ID to to shuffle the playlist. 10476 * @param {boolean} repeatState - The state you want the repeat playlist to be in. 10477 */ 10478 function setRepeatPlaylist(playlist, repeatState) { 10479 _repeater2.default.setRepeatPlaylist(repeatState, playlist); 10480 _repeatElements2.default.syncRepeatPlaylist(playlist); 10481 } 10482 10483 /** 10484 * Sets the repeat state for the song. 10485 * 10486 * Public Accessor: Amplitude.setRepeatSong() 10487 * 10488 * @access public 10489 * @param {boolean} repeatState - The state you want the repeat song status to be in. 10490 */ 10491 function setRepeatSong(repeatState) { 10492 if (!_config2.default.is_touch_moving) { 10493 /* 10494 Sets repeat to the opposite of what it was set to 10495 */ 10496 _repeater2.default.setRepeatSong(!_config2.default.repeat_song); 10497 10498 /* 10499 Visually sync repeat song 10500 */ 10501 _repeatElements2.default.syncRepeatSong(); 10502 } 10503 } 10504 10505 /** 10506 * Gets the default album art for the player 10507 * 10508 * Public Accessor: Amplitude.getDefaultAlbumArt() 10509 * 10510 * @access public 10511 */ 10512 function getDefaultAlbumArt() { 10513 return _config2.default.default_album_art; 10514 } 10515 10516 /** 10517 * Gets the default playlist art for the playlists 10518 * 10519 * Public Accessor: Amplitude.getDefaultPlaylistArt() 10520 * 10521 * @access public 10522 */ 10523 function getDefaultPlaylistArt() { 10524 return _config2.default.default_playlist_art; 10525 } 10526 10527 /** 10528 * Sets the default album art for the player 10529 * 10530 * Public Accessor: Amplitude.setDefaultAlbumArt( url ) 10531 * 10532 * @access public 10533 * @param {string} url - A string representing the URL of the new default album art. 10534 */ 10535 function setDefaultAlbumArt(url) { 10536 _config2.default.default_album_art = url; 10537 } 10538 10539 /** 10540 * Sets the default playlist art for the player 10541 * 10542 * Public Accessor: Amplitude.setDefaultPlaylistArt( url ) 10543 * 10544 * @access public 10545 * @param {string} url - A string representing the URL of the new default playlist art. 10546 */ 10547 function setDefaultPlaylistArt(url) { 10548 _config2.default.default_plalist_art = url; 10549 } 10550 10551 /** 10552 * Allows the user to get the percentage of the song played. 10553 * 10554 * Public Accessor: Amplitude.getSongPlayedPercentage(); 10555 * 10556 * @access public 10557 */ 10558 function getSongPlayedPercentage() { 10559 /* 10560 Returns the percentage of the song played. 10561 */ 10562 return _config2.default.audio.currentTime / _config2.default.audio.duration * 100; 10563 } 10564 10565 /** 10566 * Allows the user to get the amount of seconds the song has played. 10567 * 10568 * Public Accessor: Amplitude.getSongPlayed(); 10569 * 10570 * @access public 10571 */ 10572 function getSongPlayedSeconds() { 10573 /* 10574 Returns the amount of seconds the song has played. 10575 */ 10576 return _config2.default.audio.currentTime; 10577 } 10578 10579 /** 10580 * Allows the user to get the duration of the current song 10581 * 10582 * Public Accessor: Amplitude.getSongPlayed(); 10583 * 10584 * @access public 10585 */ 10586 function getSongDuration() { 10587 /* 10588 Returns the duration of the current song 10589 */ 10590 return _config2.default.audio.duration; 10591 } 10592 10593 /** 10594 * Allows the user to set how far into the song they want to be. This is 10595 * helpful for implementing custom range sliders. Only works on the current song. 10596 * 10597 * Public Accessor: Amplitude.setSongPlayedPercentage( float ); 10598 * 10599 * @access public 10600 * @param {number} percentage - The percentage of the song played 10601 */ 10602 function setSongPlayedPercentage(percentage) { 10603 /* 10604 Ensures the percentage is a number and is between 0 and 100. 10605 */ 10606 if (typeof percentage == "number" && percentage > 0 && percentage < 100) { 10607 /* 10608 Sets the current time of the song to the percentage. 10609 */ 10610 _config2.default.audio.currentTime = _config2.default.audio.duration * (percentage / 100); 10611 } 10612 } 10613 10614 /** 10615 * Allows the user to turn on debugging. 10616 * 10617 * Public Accessor: Amplitude.setDebug( bool ); 10618 * 10619 * @access public 10620 * @param {boolean} state - Turns debugging on and off. 10621 */ 10622 function setDebug(state) { 10623 /* 10624 Sets the global config debug on or off. 10625 */ 10626 _config2.default.debug = state; 10627 } 10628 10629 /** 10630 * Returns the active song meta data for the user to do what is 10631 * needed. 10632 * 10633 * Public Accessor: Amplitude.getActiveSongMetadata(); 10634 * 10635 * @access public 10636 * @returns {object} JSON Object with the active song information 10637 */ 10638 function getActiveSongMetadata() { 10639 return _config2.default.active_metadata; 10640 } 10641 10642 /** 10643 * Returns the active playlist meta data for the for the user to use. 10644 * 10645 * Public Accessor: Amplitude.getActivePlaylistMetadata(); 10646 * 10647 * @access public 10648 * @returns {object} JSON representation for the active playlist 10649 */ 10650 function getActivePlaylistMetadata() { 10651 return _config2.default.playlists[_config2.default.active_playlist]; 10652 } 10653 10654 /** 10655 * Returns a song in the songs array at that index 10656 * 10657 * Public Accessor: Amplitude.getSongAtIndex( song_index ) 10658 * 10659 * @access public 10660 * @param {number} index - The integer for the index of the song in the songs array. 10661 * @returns {object} JSON representation for the song at a specific index. 10662 */ 10663 function getSongAtIndex(index) { 10664 return _config2.default.songs[index]; 10665 } 10666 10667 /** 10668 * Returns a song at a playlist index 10669 * 10670 * Public Accessor: Amplitude.getSongAtPlaylistIndex( playlist, index 10671 * 10672 * @access public 10673 * @param {number} index - The integer for the index of the song in the playlist. 10674 * @param {string} playlist - The key of the playlist we are getting the song at the index for 10675 * @returns {object} JSON representation for the song at a specific index. 10676 */ 10677 function getSongAtPlaylistIndex(playlist, index) { 10678 var song = _config2.default.playlists[playlist].songs[index]; 10679 10680 return song; 10681 } 10682 10683 /** 10684 * Adds a song to the end of the config array. This will allow Amplitude 10685 * to play the song in a playlist type setting. 10686 * 10687 * Public Accessor: Amplitude.addSong( song_json ) 10688 * 10689 * @access public 10690 * @param {object} song - JSON representation of a song. 10691 * @returns {number} New index of the song. 10692 */ 10693 function addSong(song) { 10694 /* 10695 Ensures we have a songs array to push to. 10696 */ 10697 if (_config2.default.songs == undefined) { 10698 _config2.default.songs = []; 10699 } 10700 10701 _config2.default.songs.push(song); 10702 10703 if (_config2.default.shuffle_on) { 10704 _config2.default.shuffle_list.push(song); 10705 } 10706 10707 if (_soundcloud2.default.isSoundCloudURL(song.url)) { 10708 _soundcloud2.default.resolveIndividualStreamableURL(song.url, null, _config2.default.songs.length - 1, _config2.default.shuffle_on); 10709 } 10710 10711 return _config2.default.songs.length - 1; 10712 } 10713 10714 /** 10715 * Adds a song to the beginning of the config array. 10716 * This will allow Amplitude to play the song in a 10717 * playlist type setting. 10718 * 10719 * Public Accessor: Amplitude.addSong( song_json ) 10720 * 10721 * @access public 10722 * @param {object} song - JSON representation of a song. 10723 * @returns {number} New index of the song (0) 10724 */ 10725 function prependSong(song) { 10726 /* 10727 Ensures we have a songs array to push to. 10728 */ 10729 if (_config2.default.songs == undefined) { 10730 _config2.default.songs = []; 10731 } 10732 10733 _config2.default.songs.unshift(song); 10734 10735 if (_config2.default.shuffle_on) { 10736 _config2.default.shuffle_list.unshift(song); 10737 } 10738 10739 if (_soundcloud2.default.isSoundCloudURL(song.url)) { 10740 _soundcloud2.default.resolveIndividualStreamableURL(song.url, null, _config2.default.songs.length - 1, _config2.default.shuffle_on); 10741 } 10742 10743 return 0; 10744 } 10745 10746 /** 10747 * Adds a song to a playlist. This will allow Amplitude to play the song in the 10748 * playlist 10749 * 10750 * Public Accessor: Amplitude.addSongToPlaylist( song_json, playlist_key ) 10751 * 10752 * @access public 10753 * @param {object} song - JSON representation of a song. 10754 * @param {string} playlist - Playlist we are adding the song to. 10755 * @returns {mixed} New index of song in playlist or null if no playlist exists 10756 */ 10757 function addSongToPlaylist(song, playlist) { 10758 if (_config2.default.playlists[playlist] != undefined) { 10759 _config2.default.playlists[playlist].songs.push(song); 10760 10761 if (_config2.default.playlists[playlist].shuffle) { 10762 _config2.default.playlists[playlist].shuffle_list.push(song); 10763 } 10764 10765 if (_soundcloud2.default.isSoundCloudURL(song.url)) { 10766 _soundcloud2.default.resolveIndividualStreamableURL(song.url, playlist, _config2.default.playlists[playlist].songs.length - 1, _config2.default.playlists[playlist].shuffle); 10767 } 10768 10769 return _config2.default.playlists[playlist].songs.length - 1; 10770 } else { 10771 _debug2.default.writeMessage("Playlist doesn't exist!"); 10772 return null; 10773 } 10774 } 10775 10776 /** 10777 * Adds a playlist to Amplitude. 10778 * 10779 * @param {string} key - The key of the playlist we are adding. 10780 * @param {object} data - The data relating to the playlist 10781 * @param {array} songs - The songs to add to the playlist 10782 */ 10783 function addPlaylist(key, data, songs) { 10784 /* 10785 Ensures the playlist is not already defined. 10786 */ 10787 if (_config2.default.playlists[key] == undefined) { 10788 /* 10789 Initialize the new playlist object. 10790 */ 10791 _config2.default.playlists[key] = {}; 10792 10793 /* 10794 Define the ignored keys that we don't want to copy over. 10795 */ 10796 var ignoredKeys = ["repeat", "shuffle", "shuffle_list", "songs", "src"]; 10797 10798 /* 10799 Iterate over all of the keys defined by the user and 10800 set them on the playlist. 10801 */ 10802 for (var dataKey in data) { 10803 if (ignoredKeys.indexOf(dataKey) < 0) { 10804 _config2.default.playlists[key][dataKey] = data[dataKey]; 10805 } 10806 } 10807 10808 /* 10809 Initialize the default parameters for the playlist and set the songs. 10810 */ 10811 _config2.default.playlists[key].songs = songs; 10812 _config2.default.playlists[key].active_index = null; 10813 _config2.default.playlists[key].repeat = false; 10814 _config2.default.playlists[key].shuffle = false; 10815 _config2.default.playlists[key].shuffle_list = []; 10816 10817 return _config2.default.playlists[key]; 10818 } else { 10819 _debug2.default.writeMessage("A playlist already exists with that key!"); 10820 return null; 10821 } 10822 } 10823 10824 /** 10825 * Removes a song from the song array 10826 * 10827 * Public Accessor: Amplitude.removeSong( index ) 10828 * 10829 * @access public 10830 * @param {integer} index - Index of the song being removed 10831 * @returns {boolean} True if removed false if not. 10832 */ 10833 function removeSong(index) { 10834 _config2.default.songs.splice(index, 1); 10835 } 10836 10837 /** 10838 * Removes a song from the playlist 10839 * 10840 * Public Accessor: Amplitude.removeSongFromPlaylist( index, playlist ) 10841 * 10842 * @access public 10843 * @param {integer} index - Index of the song being removed from the playlist. 10844 * @param {string} playlist - Playlist we are removing the song from. 10845 * @returns {boolean} True if removed false if not. 10846 */ 10847 function removeSongFromPlaylist(index, playlist) { 10848 if (_config2.default.playlists[playlist] != undefined) { 10849 _config2.default.playlists[playlist].songs.splice(index, 1); 10850 } 10851 } 10852 10853 /** 10854 * When you pass a song object it plays that song right awawy. It sets 10855 * the active song in the config to the song you pass in and synchronizes 10856 * the visuals. 10857 * 10858 * Public Accessor: Amplitude.playNow( song ) 10859 * 10860 * @access public 10861 * @param {object} song - JSON representation of a song. 10862 */ 10863 function playNow(song) { 10864 /* 10865 Makes sure the song object has a URL associated with it 10866 or there will be nothing to play. 10867 */ 10868 if (song.url) { 10869 _config2.default.audio.src = song.url; 10870 _config2.default.active_metadata = song; 10871 _config2.default.active_album = song.album; 10872 } else { 10873 /* 10874 Write error message since the song passed in doesn't 10875 have a URL. 10876 */ 10877 _debug2.default.writeMessage("The song needs to have a URL!"); 10878 } 10879 10880 /* 10881 Plays the song. 10882 */ 10883 _core2.default.play(); 10884 10885 /* 10886 Sets the main song control status visual 10887 */ 10888 _playPauseElements2.default.sync(); 10889 10890 /* 10891 Update the song meta data 10892 */ 10893 _metaDataElements2.default.displayMetaData(); 10894 10895 /* 10896 Reset the song sliders, song progress bar info, and 10897 reset times. This ensures everything stays in sync. 10898 */ 10899 _songSliderElements2.default.resetElements(); 10900 10901 /* 10902 Reset the song played progress elements. 10903 */ 10904 _songPlayedProgressElements2.default.resetElements(); 10905 10906 /* 10907 Reset all of the current time elements. 10908 */ 10909 _timeElements2.default.resetCurrentTimes(); 10910 10911 /* 10912 Reset all of the duration time elements. 10913 */ 10914 _timeElements2.default.resetDurationTimes(); 10915 } 10916 10917 /** 10918 * Plays a song at the index passed in from the songs array. 10919 * 10920 * Public Accessor: Amplitude.playSongAtIndex( index ) 10921 * 10922 * @access public 10923 * @param {number} index - The number representing the song in the songs array. 10924 */ 10925 function playSongAtIndex(index) { 10926 /* 10927 Stop the current song. 10928 */ 10929 _core2.default.stop(); 10930 10931 /* 10932 Determine if there is a new playlist, if so set the active playlist and change the song. 10933 */ 10934 if (_checks2.default.newPlaylist(null)) { 10935 _audioNavigation2.default.setActivePlaylist(null); 10936 10937 _audioNavigation2.default.changeSong(_config2.default.songs[index], index); 10938 } 10939 10940 /* 10941 Check if the song is new. If so, change the song. 10942 */ 10943 if (_checks2.default.newSong(null, index)) { 10944 _audioNavigation2.default.changeSong(_config2.default.songs[index], index); 10945 } 10946 10947 /* 10948 Play the song 10949 */ 10950 _core2.default.play(); 10951 10952 /* 10953 Sync all of the play pause buttons. 10954 */ 10955 _playPauseElements2.default.sync(); 10956 } 10957 10958 /** 10959 * Plays a song at the index passed in for the playlist provided. The index passed 10960 * in should be the index of the song in the playlist and not the songs array. 10961 * 10962 * @access public 10963 * @param {number} index - The number representing the song in the playlist array. 10964 * @param {string} playlist - The key string representing the playlist we are playing the song from. 10965 * 10966 */ 10967 function playPlaylistSongAtIndex(index, playlist) { 10968 _core2.default.stop(); 10969 10970 /* 10971 Determine if there is a new playlist, if so set the active playlist and change the song. 10972 */ 10973 if (_checks2.default.newPlaylist(playlist)) { 10974 _audioNavigation2.default.setActivePlaylist(playlist); 10975 10976 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[index], index); 10977 } 10978 10979 /* 10980 Check if the song is new. If so, change the song. 10981 */ 10982 if (_checks2.default.newSong(playlist, index)) { 10983 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[index], index); 10984 } 10985 10986 /* 10987 Sync all of the play pause buttons. 10988 */ 10989 _playPauseElements2.default.sync(); 10990 10991 /* 10992 Play the song 10993 */ 10994 _core2.default.play(); 10995 } 10996 10997 /** 10998 * Allows the user to play whatever the active song is directly 10999 * through Javascript. Normally ALL of Amplitude functions that access 11000 * the core features are called through event handlers. 11001 * 11002 * Public Accessor: Amplitude.play(); 11003 * 11004 * @access public 11005 */ 11006 function play() { 11007 _core2.default.play(); 11008 } 11009 11010 /** 11011 * Allows the user to pause whatever the active song is directly 11012 * through Javascript. Normally ALL of Amplitude functions that access 11013 * the core features are called through event handlers. 11014 * 11015 * Public Accessor: Amplitude.pause(); 11016 * 11017 * @access public 11018 */ 11019 function pause() { 11020 _core2.default.pause(); 11021 } 11022 11023 /** 11024 * Allows the user to stop whatever the active song is directly 11025 * through Javascript. 11026 * 11027 * Public Accessor: Amplitude.stop(); 11028 * 11029 * @access public 11030 */ 11031 function stop() { 11032 _core2.default.stop(); 11033 } 11034 11035 /** 11036 * Returns the audio object used to play the audio 11037 * 11038 * Public Accessor: Amplitude.getAudio(); 11039 * 11040 * @access public 11041 */ 11042 function getAudio() { 11043 return _config2.default.audio; 11044 } 11045 11046 /** 11047 * Returns the Web Audio API ANalyser used for visualizations. 11048 * 11049 * Public Accessor: Amplitude.getAnalyser() 11050 * 11051 * @access public 11052 */ 11053 function getAnalyser() { 11054 return _config2.default.analyser; 11055 } 11056 11057 /** 11058 * Plays the next song either in the playlist or globally. 11059 * 11060 * Public Accessor: Amplitude.next( playlist ); 11061 * 11062 * @access public 11063 * @param {string} [playlist = null - The playlist key 11064 */ 11065 function next() { 11066 var playlist = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 11067 11068 var nextData = {}; 11069 /* 11070 If the playlist is empty or null, then we check the active 11071 playlist 11072 */ 11073 if (playlist == "" || playlist == null) { 11074 /* 11075 If the active playlist is null, then we set the next global 11076 song or we set the next in the playlist. 11077 */ 11078 if (_config2.default.active_playlist == null || _config2.default.active_playlist == "") { 11079 _audioNavigation2.default.setNext(); 11080 } else { 11081 _audioNavigation2.default.setNextPlaylist(_config2.default.active_playlist); 11082 } 11083 } else { 11084 _audioNavigation2.default.setNextPlaylist(playlist); 11085 } 11086 } 11087 11088 /** 11089 * Plays the prev song either in the playlist or globally. 11090 * 11091 * Public Accessor: Amplitude.prev( playlist ); 11092 * 11093 * @access public 11094 * @param {string} [playlist = null] - The playlist key 11095 */ 11096 function prev() { 11097 var playlist = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 11098 11099 var prevData = {}; 11100 11101 /* 11102 If the playlist is empty or null, then we check the active 11103 playlist 11104 */ 11105 if (playlist == "" || playlist == null) { 11106 /* 11107 If the active playlist is null, then we set the prev global 11108 song or we set the prev in the playlist. 11109 */ 11110 if (_config2.default.active_playlist == null || _config2.default.active_playlist == "") { 11111 _audioNavigation2.default.setPrevious(); 11112 } else { 11113 _audioNavigation2.default.setPreviousPlaylist(_config2.default.active_playlist); 11114 } 11115 } else { 11116 _audioNavigation2.default.setPreviousPlaylist(playlist); 11117 } 11118 } 11119 11120 /** 11121 * Gets all of the songs in the songs array 11122 * 11123 * Public Accessor: Amplitude.getSongs( ); 11124 * 11125 * @access public 11126 */ 11127 function getSongs() { 11128 return _config2.default.songs; 11129 } 11130 11131 /** 11132 * Gets all of the songs in a playlist 11133 * 11134 * Public Accessor: Amplitude.getSongsInPlaylist( playlist ); 11135 * 11136 * @access public 11137 * @param {string} playlist - The playlist key 11138 */ 11139 function getSongsInPlaylist(playlist) { 11140 return _config2.default.playlists[playlist].songs; 11141 } 11142 11143 /** 11144 * Get current state of songs. If shuffled, this will return the shuffled 11145 * songs. 11146 * 11147 * Public Accessor: Amplitude.getSongsState(); 11148 * 11149 * @access public 11150 */ 11151 function getSongsState() { 11152 if (_config2.default.shuffle_on) { 11153 return _config2.default.shuffle_list; 11154 } else { 11155 return _config2.default.songs; 11156 } 11157 } 11158 11159 /** 11160 * Get current state of songs in playlist. If shuffled, this will return the 11161 * shuffled songs. 11162 * 11163 * Public Accessor: Amplitude.getSongsStatePlaylist( playlist ); 11164 * 11165 * @access public 11166 * @param {string} playlist - The playlist key 11167 */ 11168 function getSongsStatePlaylist(playlist) { 11169 if (_config2.default.playlists[playlist].shuffle) { 11170 return _config2.default.playlists[playlist].shuffle_list; 11171 } else { 11172 return _config2.default.playlists[playlist].songs; 11173 } 11174 } 11175 11176 /** 11177 * Gets the active index of the player 11178 * 11179 * Public Accessor: Amplitude.getActiveIndex() 11180 * 11181 * @access public 11182 */ 11183 function getActiveIndex() { 11184 return parseInt(_config2.default.active_index); 11185 } 11186 11187 /** 11188 * Get the version of AmplitudeJS 11189 * 11190 * Public Accessor: Amplitude.getVersion() 11191 * 11192 * @access public 11193 */ 11194 function getVersion() { 11195 return _config2.default.version; 11196 } 11197 11198 /** 11199 * Get the buffered amount for the current song 11200 * 11201 * Public Accessor: Amplitude.getBuffered() 11202 * 11203 * @access public 11204 */ 11205 function getBuffered() { 11206 return _config2.default.buffered; 11207 } 11208 11209 /** 11210 * Skip to a certain location in a selected song. 11211 * 11212 * Public Accessor: Amplitude.getBuffered() 11213 * 11214 * @access public 11215 * @param {number} seconds - The amount of seconds we should skip to in the song. 11216 * @param {number} songIndex - The index of the song in the songs array. 11217 * @param {string} [playlist = null] - The playlist the song we are skipping to belogns to. 11218 */ 11219 function skipTo(seconds, songIndex) { 11220 var playlist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 11221 11222 seconds = parseInt(seconds); 11223 11224 if (playlist != null) { 11225 /* 11226 Checks if we are skipping to a new playlist 11227 */ 11228 if (_checks2.default.newPlaylist(playlist)) { 11229 _audioNavigation2.default.setActivePlaylist(playlist); 11230 } 11231 11232 /* 11233 Changes the song to where it's being skipped and then 11234 play the song. 11235 */ 11236 _audioNavigation2.default.changeSongPlaylist(playlist, _config2.default.playlists[playlist].songs[songIndex], songIndex); 11237 _core2.default.play(); 11238 11239 /* 11240 Sync all of the play pause elements. 11241 */ 11242 _playPauseElements2.default.syncGlobal(); 11243 _playPauseElements2.default.syncPlaylist(); 11244 _playPauseElements2.default.syncSong(); 11245 11246 /* 11247 Skip to the location in the song. 11248 */ 11249 _core2.default.skipToLocation(seconds); 11250 } else { 11251 /* 11252 Changes the song to where it's being skipped and then 11253 play the song. 11254 */ 11255 _audioNavigation2.default.changeSong(_config2.default.songs[songIndex], songIndex); 11256 _core2.default.play(); 11257 11258 /* 11259 Syncs all of the play pause buttons now that we've skipped. 11260 */ 11261 _playPauseElements2.default.syncGlobal(); 11262 _playPauseElements2.default.syncSong(); 11263 11264 /* 11265 Skip to the location in the song. 11266 */ 11267 _core2.default.skipToLocation(seconds); 11268 } 11269 } 11270 11271 /** 11272 * Sets the meta data for a song in the songs array. This will set any 11273 * meta data for a song besides the URL. The URL could cause issues if the 11274 * song was playing. 11275 * 11276 * Public Accessor: Amplitude.setSongMetaData() 11277 * 11278 * @access public 11279 * @param {number} index - The index of the song in the songs array. 11280 * @param {object} metaData - The object containing the meta data we are updating. 11281 * @param {string} playlist - The playlist we are updating the song meta data for. 11282 */ 11283 function setSongMetaData(index, metaData) { 11284 var playlist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 11285 11286 /* 11287 Update the meta data for a song in a playlist. 11288 */ 11289 if (playlist != "" && playlist != null && _config2.default.playlists[playlist] != undefined) { 11290 /* 11291 Set all of the defined meta data properties 11292 */ 11293 for (var key in metaData) { 11294 if (metaData.hasOwnProperty(key)) { 11295 if (key != "url" && key != "URL" && key != "live" && key != "LIVE") { 11296 _config2.default.playlists[playlist].songs[index][key] = metaData[key]; 11297 } 11298 } 11299 } 11300 } else { 11301 /* 11302 Update the meta data for a song. 11303 */ 11304 for (var key in metaData) { 11305 if (metaData.hasOwnProperty(key)) { 11306 if (key != "url" && key != "URL" && key != "live" && key != "LIVE") { 11307 _config2.default.songs[index][key] = metaData[key]; 11308 } 11309 } 11310 } 11311 } 11312 11313 /* 11314 Display the updates on the screen. 11315 */ 11316 _metaDataElements2.default.displayMetaData(); 11317 _metaDataElements2.default.syncMetaData(); 11318 } 11319 11320 function setPlaylistMetaData(playlist, metaData) { 11321 if (_config2.default.playlists[playlist] != undefined) { 11322 /* 11323 These are the ignored keys that we won't be worrying about displaying. 11324 Every other key in the playlist object can be displayed. 11325 */ 11326 var ignoredKeys = ["repeat", "shuffle", "shuffle_list", "songs", "src"]; 11327 11328 for (var key in metaData) { 11329 if (metaData.hasOwnProperty(key)) { 11330 if (ignoredKeys.indexOf(key) < 0) { 11331 _config2.default.playlists[playlist][key] = metaData[key]; 11332 } 11333 } 11334 } 11335 11336 _metaDataElements2.default.displayPlaylistMetaData(); 11337 } else { 11338 _debug2.default.writeMessage("You must provide a valid playlist key!"); 11339 } 11340 } 11341 11342 /** 11343 * Sets the delay between the songs when they are finished. 11344 * 11345 * Public Accessor: Amplitude.setDelay() 11346 * 11347 * @access public 11348 * @param {number} delay - The millisecond delay time between songs 11349 */ 11350 function setDelay(time) { 11351 _config2.default.delay = time; 11352 } 11353 11354 /** 11355 * Returns the current delay between songs. 11356 * 11357 * Public Accessor: Amplitude.getDelay() 11358 * 11359 * @access public 11360 */ 11361 function getDelay() { 11362 return _config2.default.delay; 11363 } 11364 11365 /** 11366 * Returns the state of the player. 11367 * 11368 * Public Accessor: Amplitude.getPlayerState(); 11369 */ 11370 function getPlayerState() { 11371 return _config2.default.player_state; 11372 } 11373 11374 /** 11375 * Registers a visualization and sets that visualization's 11376 * preferences. When creating a visualization, you can set certain 11377 * preferences that the user can overwrite similar to Amplitude. 11378 * Public Accessor: Amplitude.registerVisualization( visualization, preferences ) 11379 * 11380 * @param {object} visualzation A visualization object that gets registered 11381 * with Amplitude 11382 * 11383 * @param {object} preferences A JSON object of preferences relating to the 11384 * visualization 11385 */ 11386 function registerVisualization(visualization, preferences) { 11387 _visualizations2.default.register(visualization, preferences); 11388 } 11389 11390 /** 11391 * Set the visualization for the playlist 11392 * 11393 * @param {string} playlist - The playlist we are setting the visualization for. 11394 * @param {string} visualizationKey - The key of the visualization we are adding to the playlist. 11395 */ 11396 function setPlaylistVisualization(playlist, visualizationKey) { 11397 if (_config2.default.playlists[playlist] != undefined) { 11398 if (_config2.default.visualizations.available[visualizationKey] != undefined) { 11399 _config2.default.playlists[playlist].visualization = visualizationKey; 11400 } else { 11401 _debug2.default.writeMessage("A visualization does not exist for the key provided."); 11402 } 11403 } else { 11404 _debug2.default.writeMessage("The playlist for the key provided does not exist"); 11405 } 11406 } 11407 11408 /** 11409 * Set a visualization for the song. 11410 * 11411 * @param {number} songIndex - The index of the song in the songs array we are setting the visualization for. 11412 * @param {string} visualizationKey - The key of the visualization we are adding to the playlist. 11413 */ 11414 function setSongVisualization(songIndex, visualizationKey) { 11415 if (_config2.default.songs[songIndex]) { 11416 if (_config2.default.visualizations.available[visualizationKey] != undefined) { 11417 _config2.default.songs[songIndex].visualization = visualizationKey; 11418 } else { 11419 _debug2.default.writeMessage("A visualization does not exist for the key provided."); 11420 } 11421 } else { 11422 _debug2.default.writeMessage("A song at that index is undefined"); 11423 } 11424 } 11425 11426 /** 11427 * Set song in playlist visualization. 11428 * 11429 * @param {string} playlist - The playlist we are setting the song visualization for. 11430 * @param {number} songIndex - The index we are setting the visualization for. 11431 * @param {strong} visualizationKey - The key of the visualization we are adding to the song in the playlist. 11432 */ 11433 function setSongInPlaylistVisualization(playlist, songIndex, visualizationKey) { 11434 if (_config2.default.playlists[playlist].songs[songIndex] != undefined) { 11435 if (_config2.default.visualizations.available[visualizationKey] != undefined) { 11436 _config2.default.playlists[playlist].songs[songIndex].visualization = visualizationKey; 11437 } else { 11438 _debug2.default.writeMessage("A visualization does not exist for the key provided."); 11439 } 11440 } else { 11441 _debug2.default.writeMessage("The song in the playlist at that key is not defined"); 11442 } 11443 } 11444 11445 /** 11446 * Sets the global visualization default. 11447 */ 11448 function setGlobalVisualization(visualizationKey) { 11449 if (_config2.default.visualizations.available[visualizationKey] != undefined) { 11450 _config2.default.visualization = visualizationKey; 11451 } else { 11452 _debug2.default.writeMessage("A visualization does not exist for the key provided."); 11453 } 11454 } 11455 11456 /** 11457 * Sets the active volume. 11458 * @param {number} volumeLevel - A number between 1 and 100 as a percentage of 11459 * min to max for a volume level. 11460 */ 11461 function setVolume(volumeLevel) { 11462 _core2.default.setVolume(volumeLevel); 11463 } 11464 11465 /** 11466 * Gets the active volume. 11467 */ 11468 function getVolume() { 11469 return _config2.default.volume; 11470 } 11471 11472 /* 11473 Returns all of the publically accesible methods. 11474 */ 11475 return { 11476 init: init, 11477 getConfig: getConfig, 11478 bindNewElements: bindNewElements, 11479 getActivePlaylist: getActivePlaylist, 11480 getPlaybackSpeed: getPlaybackSpeed, 11481 setPlaybackSpeed: setPlaybackSpeed, 11482 getRepeat: getRepeat, 11483 getRepeatPlaylist: getRepeatPlaylist, 11484 getShuffle: getShuffle, 11485 getShufflePlaylist: getShufflePlaylist, 11486 setShuffle: setShuffle, 11487 setShufflePlaylist: setShufflePlaylist, 11488 setRepeat: setRepeat, 11489 setRepeatSong: setRepeatSong, 11490 setRepeatPlaylist: setRepeatPlaylist, 11491 getDefaultAlbumArt: getDefaultAlbumArt, 11492 setDefaultAlbumArt: setDefaultAlbumArt, 11493 getDefaultPlaylistArt: getDefaultPlaylistArt, 11494 setDefaultPlaylistArt: setDefaultPlaylistArt, 11495 getSongPlayedPercentage: getSongPlayedPercentage, 11496 setSongPlayedPercentage: setSongPlayedPercentage, 11497 getSongPlayedSeconds: getSongPlayedSeconds, 11498 getSongDuration: getSongDuration, 11499 setDebug: setDebug, 11500 getActiveSongMetadata: getActiveSongMetadata, 11501 getActivePlaylistMetadata: getActivePlaylistMetadata, 11502 getSongAtIndex: getSongAtIndex, 11503 getSongAtPlaylistIndex: getSongAtPlaylistIndex, 11504 addSong: addSong, 11505 prependSong: prependSong, 11506 addSongToPlaylist: addSongToPlaylist, 11507 removeSong: removeSong, 11508 removeSongFromPlaylist: removeSongFromPlaylist, 11509 playNow: playNow, 11510 playSongAtIndex: playSongAtIndex, 11511 playPlaylistSongAtIndex: playPlaylistSongAtIndex, 11512 play: play, 11513 pause: pause, 11514 stop: stop, 11515 getAudio: getAudio, 11516 getAnalyser: getAnalyser, 11517 next: next, 11518 prev: prev, 11519 getSongs: getSongs, 11520 getSongsInPlaylist: getSongsInPlaylist, 11521 getSongsState: getSongsState, 11522 getSongsStatePlaylist: getSongsStatePlaylist, 11523 getActiveIndex: getActiveIndex, 11524 getVersion: getVersion, 11525 getBuffered: getBuffered, 11526 skipTo: skipTo, 11527 setSongMetaData: setSongMetaData, 11528 setPlaylistMetaData: setPlaylistMetaData, 11529 setDelay: setDelay, 11530 getDelay: getDelay, 11531 getPlayerState: getPlayerState, 11532 addPlaylist: addPlaylist, 11533 registerVisualization: registerVisualization, 11534 setPlaylistVisualization: setPlaylistVisualization, 11535 setSongVisualization: setSongVisualization, 11536 setSongInPlaylistVisualization: setSongInPlaylistVisualization, 11537 setGlobalVisualization: setGlobalVisualization, 11538 getVolume: getVolume, 11539 setVolume: setVolume 11540 }; 11541}(); 11542 11543/** 11544 * Playback Speed Elements 11545 * @module visual/PlaybackSpeedElements 11546 */ 11547 11548 11549/** 11550 * Play Pause Elements 11551 * @module visual/PlayPauseElements 11552 */ 11553 11554 11555/** 11556 * Song Played Progress Elements 11557 * @module visual/SongPlayedProgressElements 11558 */ 11559 11560 11561/** 11562 * Visual Repeat Elements 11563 * @module visual/RepeatElements 11564 */ 11565 11566 11567/**************************************************** 11568 * FX Modules 11569 ****************************************************/ 11570/** 11571 * Imports the visualizations module 11572 * @module fx/Visualizations 11573 */ 11574 11575 11576/** 11577 * Repeater Module 11578 * 11579 * @module utilities/Repeater 11580 */ 11581 11582 11583/** 11584 * Imports the config state module. 11585 * @module ConfigState 11586 */ 11587 11588 11589/**************************************************** 11590 * Core 11591 ****************************************************/ 11592/** 11593 * AmplitudeJS Core Module 11594 * 11595 * @module core/Core 11596 */ 11597/** 11598 * @name AmplitudeJS 11599 * @author Dan Pastori (Server Side Up) <[email protected]> 11600 */ 11601/** 11602 * AmplitudeJS Initializer Module 11603 * 11604 * @module init/AmplitudeInitializer 11605 */ 11606exports.default = Amplitude; 11607module.exports = exports["default"]; 11608 11609/***/ }), 11610/* 48 */ 11611/***/ (function(module, exports, __webpack_require__) { 11612 11613"use strict"; 11614 11615 11616Object.defineProperty(exports, "__esModule", { 11617 value: true 11618}); 11619 11620var _config = __webpack_require__(0); 11621 11622var _config2 = _interopRequireDefault(_config); 11623 11624var _debug = __webpack_require__(4); 11625 11626var _debug2 = _interopRequireDefault(_debug); 11627 11628var _checks = __webpack_require__(5); 11629 11630var _checks2 = _interopRequireDefault(_checks); 11631 11632var _metaDataElements = __webpack_require__(7); 11633 11634var _metaDataElements2 = _interopRequireDefault(_metaDataElements); 11635 11636var _soundcloud = __webpack_require__(17); 11637 11638var _soundcloud2 = _interopRequireDefault(_soundcloud); 11639 11640function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11641 11642/** 11643 * Handles the initialization of the playlists. 11644 * 11645 * @module init/PlaylistsInitializer 11646 */ 11647 11648 11649/** 11650 * AmplitudeJS Visual Meta Data Elements Module 11651 * @module visual/MetaDataElements 11652 */ 11653 11654 11655/** 11656 * AmplitudeJS Debug Module 11657 * @module utilities/Debug 11658 */ 11659var PlaylistsInitializer = function () { 11660 /** 11661 * Initializes the playlists for AmplitudeJS 11662 * 11663 * @param {Object} playlists - The playlists defined by the user. 11664 */ 11665 function initialize(playlists) { 11666 /* 11667 Copy the playlists over to Amplitude 11668 */ 11669 _config2.default.playlists = playlists; 11670 11671 /* 11672 Copy songs over from songs array. 11673 */ 11674 copySongsToPlaylists(); 11675 11676 /* 11677 Grab any SoundCloud Data for the playlist songs if needed. 11678 */ 11679 grabSoundCloudData(); 11680 11681 /* 11682 Initialize a scoped active index for each playlist. 11683 */ 11684 initializePlaylistActiveIndexes(); 11685 11686 /* 11687 Initialize the shuffle status of the playlists. 11688 */ 11689 initializePlaylistShuffleStatuses(); 11690 11691 /* 11692 Initialize the repeat status for the playlits. 11693 */ 11694 initializePlaylistsRepeatStatuses(); 11695 11696 /* 11697 Initialize temporary place holders for shuffle lists. 11698 */ 11699 initializePlaylistShuffleLists(); 11700 11701 /* 11702 Initializes the first song in the playlist 11703 */ 11704 initializeFirstSongInPlaylistMetaData(); 11705 } 11706 11707 /** 11708 * Initializes a scoped active index for each playlist. 11709 * 11710 * @access private 11711 */ 11712 function initializePlaylistActiveIndexes() { 11713 /* 11714 Iterate over all of the playlists defined by the user 11715 and add an active index. 11716 */ 11717 for (var key in _config2.default.playlists) { 11718 _config2.default.playlists[key].active_index = null; 11719 } 11720 } 11721 11722 /** 11723 * Ensures the indexes in the playlists are valid indexes. The song has 11724 * to exist in the Amplitude config to be played correctly. If the index 11725 * is an integer, we ensure it exists and coy it to the array. 11726 * 11727 * @access private 11728 */ 11729 function copySongsToPlaylists() { 11730 /* 11731 Iterate over all of the config's playlists 11732 */ 11733 for (var key in _config2.default.playlists) { 11734 /* 11735 Checks if the playlist key is accurate. 11736 */ 11737 if (_config2.default.playlists.hasOwnProperty(key)) { 11738 /* 11739 Checks if the playlist has songs. 11740 */ 11741 if (_config2.default.playlists[key].songs) { 11742 /* 11743 Iterate over all of the songs in the playlist 11744 */ 11745 for (var i = 0; i < _config2.default.playlists[key].songs.length; i++) { 11746 if (_checks2.default.isInt(_config2.default.playlists[key].songs[i])) { 11747 _config2.default.playlists[key].songs[i] = _config2.default.songs[_config2.default.playlists[key].songs[i]]; 11748 11749 _config2.default.playlists[key].songs[i].index = i; 11750 } 11751 /* 11752 Check to see if the index for the song in the playlist 11753 exists in the songs config. 11754 */ 11755 if (_checks2.default.isInt(_config2.default.playlists[key].songs[i]) && !_config2.default.songs[_config2.default.playlists[key].songs[i]]) { 11756 _debug2.default.writeMessage("The song index: " + _config2.default.playlists[key].songs[i] + " in playlist with key: " + key + " is not defined in your songs array!"); 11757 } 11758 11759 /* 11760 If not an int, then is a dedicated song, just set the index. 11761 */ 11762 if (!_checks2.default.isInt(_config2.default.playlists[key].songs[i])) { 11763 _config2.default.playlists[key].songs[i].index = i; 11764 } 11765 } 11766 } 11767 } 11768 } 11769 } 11770 11771 /** 11772 * Grabs the SoundCloud data for any song in the playlist that 11773 * the user needs to grab data for. 11774 * 11775 * @access private 11776 */ 11777 function grabSoundCloudData() { 11778 /* 11779 Iterate over all of the config's playlists 11780 */ 11781 for (var key in _config2.default.playlists) { 11782 /* 11783 Checks if the playlist key is accurate. 11784 */ 11785 if (_config2.default.playlists.hasOwnProperty(key)) { 11786 /* 11787 Iterate over all of the songs in the playlist and see if 11788 they need to grab the SoundCloud data for the song. 11789 */ 11790 for (var i = 0; i < _config2.default.playlists[key].songs.length; i++) { 11791 /* 11792 Only Grab the data if the URL is a SoundCloud URL. 11793 */ 11794 if (_soundcloud2.default.isSoundCloudURL(_config2.default.playlists[key].songs[i].url)) { 11795 /* 11796 Only grab the data if the SoundCloud data has not already been 11797 grabbed for the audio. This could happen if the user defined the 11798 song in the songs array and was grabbed before. 11799 */ 11800 if (_config2.default.playlists[key].songs[i].soundcloud_data == undefined) { 11801 _soundcloud2.default.resolveIndividualStreamableURL(_config2.default.playlists[key].songs[i].url, key, i); 11802 } 11803 } 11804 } 11805 } 11806 } 11807 } 11808 11809 /** 11810 * Initializes the shuffle statuses for each of the playlists. These will 11811 * be referenced when we shuffle individual playlists. 11812 * 11813 * @access private 11814 */ 11815 function initializePlaylistShuffleStatuses() { 11816 /* 11817 Iterate over all of the playlists the user defined adding 11818 the playlist key to the shuffled playlist array and creating 11819 and empty object to house the statuses. 11820 */ 11821 for (var key in _config2.default.playlists) { 11822 _config2.default.playlists[key].shuffle = false; 11823 } 11824 } 11825 11826 /** 11827 * Initializes the repeat statuses for each of the playlists. These will 11828 * be referenced when we repeat individual playlits. 11829 * 11830 * @access private 11831 */ 11832 function initializePlaylistsRepeatStatuses() { 11833 /* 11834 Iterate over all of the playlists the user defined adding 11835 the playlist key to the repeated playlist array and creating 11836 and empty object to house the statuses. 11837 */ 11838 for (var key in _config2.default.playlists) { 11839 _config2.default.playlists[key].repeat = false; 11840 } 11841 } 11842 11843 /** 11844 * Initializes the shuffled playlist placeholders. These will be set for 11845 * playlists that are shuffled and contain the shuffled songs. 11846 * 11847 * @access private 11848 */ 11849 function initializePlaylistShuffleLists() { 11850 /* 11851 Iterate over all of the playlists the user defined adding 11852 the playlist key to the shuffled playlists array and creating 11853 and empty object to house the shuffled playlists 11854 */ 11855 for (var key in _config2.default.playlists) { 11856 _config2.default.playlists[key].shuffle_list = []; 11857 } 11858 } 11859 11860 /** 11861 * Intializes the display for the first song in the playlist meta data. 11862 * 11863 * @access private 11864 */ 11865 function initializeFirstSongInPlaylistMetaData() { 11866 /* 11867 Iterates over all of the playlists setting the meta data for the 11868 first song. 11869 */ 11870 for (var key in _config2.default.playlists) { 11871 _metaDataElements2.default.setFirstSongInPlaylist(_config2.default.playlists[key].songs[0], key); 11872 } 11873 } 11874 11875 /* 11876 Returns the public facing methods 11877 */ 11878 return { 11879 initialize: initialize 11880 }; 11881}(); 11882 11883/** 11884 * AmplitudeJS SoundCloud Meta module 11885 * @module soundcloud/Soundcloud 11886 */ 11887 11888 11889/** 11890 * AmplitudeJS Checks Utility. 11891 * @module utilities/Checks 11892 */ 11893/** 11894 * Imports the config module 11895 * @module config 11896 */ 11897exports.default = PlaylistsInitializer; 11898module.exports = exports["default"]; 11899 11900/***/ }), 11901/* 49 */ 11902/***/ (function(module, exports, __webpack_require__) { 11903 11904"use strict"; 11905 11906 11907Object.defineProperty(exports, "__esModule", { 11908 value: true 11909}); 11910 11911var _config = __webpack_require__(0); 11912 11913var _config2 = _interopRequireDefault(_config); 11914 11915function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11916 11917/** 11918 * Handles all of the container elements. 11919 * 11920 * @param visual/ContainerElements 11921 */ 11922var ContainerElements = function () { 11923 /** 11924 * Applies the class 'amplitude-active-song-container' to the element 11925 * containing visual information regarding the active song. 11926 * 11927 * @prop {boolean} direct - Determines if it was a direct click on the song. We 11928 * then don't care if shuffle is on or not. 11929 * 11930 * @access public 11931 */ 11932 function setActive(direct) { 11933 /* 11934 Gets all of the song container elements. 11935 */ 11936 var songContainers = document.getElementsByClassName("amplitude-song-container"); 11937 11938 /* 11939 Removes all of the active song containrs. 11940 */ 11941 for (var i = 0; i < songContainers.length; i++) { 11942 songContainers[i].classList.remove("amplitude-active-song-container"); 11943 } 11944 11945 /* 11946 Finds the active index and adds the active song container to the element 11947 that represents the song at the index. 11948 */ 11949 if (_config2.default.active_playlist == "" || _config2.default.active_playlist == null) { 11950 var activeIndex = ""; 11951 11952 /* 11953 If we click directly on the song element, we ignore 11954 whether it's in shuffle or not. 11955 */ 11956 if (direct) { 11957 activeIndex = _config2.default.active_index; 11958 } else { 11959 if (_config2.default.shuffle_on) { 11960 activeIndex = _config2.default.shuffle_list[_config2.default.active_index].index; 11961 } else { 11962 activeIndex = _config2.default.active_index; 11963 } 11964 } 11965 11966 if (document.querySelectorAll('.amplitude-song-container[data-amplitude-song-index="' + activeIndex + '"]')) { 11967 var _songContainers = document.querySelectorAll('.amplitude-song-container[data-amplitude-song-index="' + activeIndex + '"]'); 11968 11969 for (var _i = 0; _i < _songContainers.length; _i++) { 11970 if (!_songContainers[_i].hasAttribute("data-amplitude-playlist")) { 11971 _songContainers[_i].classList.add("amplitude-active-song-container"); 11972 } 11973 } 11974 } 11975 } else { 11976 /* 11977 If we have an active playlist or the action took place directly on the 11978 song element, we ignore the shuffle. 11979 */ 11980 if (_config2.default.active_playlist != null && _config2.default.active_playlist != "" || direct) { 11981 var activePlaylistIndex = _config2.default.playlists[_config2.default.active_playlist].active_index; 11982 } else { 11983 var activePlaylistIndex = ""; 11984 11985 if (_config2.default.playlists[_config2.default.active_playlist].shuffle) { 11986 activePlaylistIndex = _config2.default.playlists[_config2.default.active_playlist].shuffle_list[_config2.default.playlists[_config2.default.active_playlist].active_index].index; 11987 } else { 11988 activePlaylistIndex = _config2.default.playlists[_config2.default.active_playlist].active_index; 11989 } 11990 } 11991 11992 if (document.querySelectorAll('.amplitude-song-container[data-amplitude-song-index="' + activePlaylistIndex + '"][data-amplitude-playlist="' + _config2.default.active_playlist + '"]')) { 11993 var _songContainers2 = document.querySelectorAll('.amplitude-song-container[data-amplitude-song-index="' + activePlaylistIndex + '"][data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 11994 11995 for (var _i2 = 0; _i2 < _songContainers2.length; _i2++) { 11996 _songContainers2[_i2].classList.add("amplitude-active-song-container"); 11997 } 11998 } 11999 } 12000 } 12001 12002 return { 12003 setActive: setActive 12004 }; 12005}(); /** 12006 * Imports the config module 12007 * @module config 12008 */ 12009exports.default = ContainerElements; 12010module.exports = exports["default"]; 12011 12012/***/ }), 12013/* 50 */ 12014/***/ (function(module, exports, __webpack_require__) { 12015 12016"use strict"; 12017 12018 12019Object.defineProperty(exports, "__esModule", { 12020 value: true 12021}); 12022 12023var _config = __webpack_require__(0); 12024 12025var _config2 = _interopRequireDefault(_config); 12026 12027function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 12028 12029/** 12030 * Handles all of the current time hour elements. 12031 * 12032 * @module visual/time/CurrentHourElements 12033 */ 12034var CurrentHourElements = function () { 12035 function sync(hours) { 12036 syncGlobal(hours); 12037 syncPlaylist(hours); 12038 syncSong(hours); 12039 syncSongInPlaylist(hours); 12040 } 12041 12042 /** 12043 * Updates any elements that display the current hour for the song. 12044 * 12045 * @access public 12046 * @param {number} hours - An integer conaining how many hours into the song. 12047 */ 12048 function syncGlobal(hours) { 12049 /* 12050 Get all of the hour selectors 12051 */ 12052 var currentHourSelectors = document.querySelectorAll(".amplitude-current-hours"); 12053 12054 /* 12055 Set the current hour selector's inner html to hours passed in. 12056 */ 12057 for (var i = 0; i < currentHourSelectors.length; i++) { 12058 var playlist = currentHourSelectors[i].getAttribute("data-amplitude-playlist"); 12059 var songIndex = currentHourSelectors[i].getAttribute("data-amplitude-song-index"); 12060 12061 /* 12062 Updates the current hour selector for a global display. 12063 */ 12064 if (playlist == null && songIndex == null) { 12065 currentHourSelectors[i].innerHTML = hours; 12066 } 12067 } 12068 } 12069 12070 /** 12071 * Syncs the playlist current hour elements. 12072 * 12073 * @param {Integer} hour - The current audio hour. 12074 */ 12075 function syncPlaylist(hours) { 12076 /* 12077 Get all of the hour selectors 12078 */ 12079 var currentHourPlaylistSelectors = document.querySelectorAll('.amplitude-current-hours[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 12080 12081 /* 12082 Set the current hour selector's inner html to hours passed in. 12083 */ 12084 for (var i = 0; i < currentHourPlaylistSelectors.length; i++) { 12085 var songIndex = currentHourPlaylistSelectors[i].getAttribute("data-amplitude-song-index"); 12086 12087 /* 12088 Updates the current hour selector for a global display. 12089 */ 12090 if (songIndex == null) { 12091 currentHourPlaylistSelectors[i].innerHTML = hours; 12092 } 12093 } 12094 } 12095 12096 /** 12097 * Syncs the song hour elements. 12098 * 12099 * @param {Integer} hour - The current audio hour. 12100 */ 12101 function syncSong(hours) { 12102 if (_config2.default.active_playlist == null) { 12103 /* 12104 Get all of the hour selectors 12105 */ 12106 var currentHourSongSelectors = document.querySelectorAll('.amplitude-current-hours[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 12107 12108 /* 12109 Set the current hour selector's inner html to hours passed in. 12110 */ 12111 for (var i = 0; i < currentHourSongSelectors.length; i++) { 12112 var playlist = currentHourSongSelectors[i].getAttribute("data-amplitude-playlist"); 12113 12114 /* 12115 Updates the current hour selector for a global display. 12116 */ 12117 if (playlist == null) { 12118 currentHourSongSelectors[i].innerHTML = hours; 12119 } 12120 } 12121 } 12122 } 12123 12124 /** 12125 * Syncs the song in playlist song hour elements. 12126 * 12127 * @param {Integer} hour - The current audio hour. 12128 */ 12129 function syncSongInPlaylist(hours) { 12130 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 12131 /* 12132 Get all of the hour selectors 12133 */ 12134 var currentHourPlaylistSongSelectors = document.querySelectorAll('.amplitude-current-hours[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 12135 12136 /* 12137 Set the current hour selector's inner html to hours passed in. 12138 */ 12139 for (var i = 0; i < currentHourPlaylistSongSelectors.length; i++) { 12140 currentHourPlaylistSongSelectors[i].innerHTML = hours; 12141 } 12142 } 12143 12144 /** 12145 * Reset the current hour elements. 12146 */ 12147 function resetTimes() { 12148 /* 12149 Gets the hour display elements 12150 */ 12151 var hourSelectors = document.querySelectorAll(".amplitude-current-hours"); 12152 12153 /* 12154 Iterates over all of the hour selectors and sets the inner HTML 12155 to 00. 12156 */ 12157 for (var i = 0; i < hourSelectors.length; i++) { 12158 hourSelectors[i].innerHTML = "00"; 12159 } 12160 } 12161 12162 /** 12163 * Returns the publically facing methods. 12164 */ 12165 return { 12166 sync: sync, 12167 resetTimes: resetTimes 12168 }; 12169}(); /** 12170 * Imports the config module 12171 * @module config 12172 */ 12173exports.default = CurrentHourElements; 12174module.exports = exports["default"]; 12175 12176/***/ }), 12177/* 51 */ 12178/***/ (function(module, exports, __webpack_require__) { 12179 12180"use strict"; 12181 12182 12183Object.defineProperty(exports, "__esModule", { 12184 value: true 12185}); 12186 12187var _config = __webpack_require__(0); 12188 12189var _config2 = _interopRequireDefault(_config); 12190 12191function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 12192 12193/** 12194 * Handles all of the current time minutes elements. 12195 * 12196 * @module visual/time/CurrentMinuteElements 12197 */ 12198var CurrentMinuteElements = function () { 12199 /** 12200 * Syncs the current minutes elements. 12201 * 12202 * @param {Integer} minutes - The current audio minutes. 12203 */ 12204 function sync(minutes) { 12205 syncGlobal(minutes); 12206 syncPlaylist(minutes); 12207 syncSong(minutes); 12208 syncSongInPlaylist(minutes); 12209 } 12210 12211 /** 12212 * Syncs the global current minutes elements. 12213 * 12214 * @param {Integer} minutes - The current audio minutes. 12215 */ 12216 function syncGlobal(minutes) { 12217 /* 12218 Get all of the minute selectors 12219 */ 12220 var currentMinuteSelectors = document.querySelectorAll(".amplitude-current-minutes"); 12221 12222 /* 12223 Set the current minute selector's inner html to minutes passed in. 12224 */ 12225 for (var i = 0; i < currentMinuteSelectors.length; i++) { 12226 var playlist = currentMinuteSelectors[i].getAttribute("data-amplitude-playlist"); 12227 var songIndex = currentMinuteSelectors[i].getAttribute("data-amplitude-song-index"); 12228 12229 /* 12230 Updates the current minute selector for a global display. 12231 */ 12232 if (playlist == null && songIndex == null) { 12233 currentMinuteSelectors[i].innerHTML = minutes; 12234 } 12235 } 12236 } 12237 12238 /** 12239 * Syncs the playlist minutes elements. 12240 * 12241 * @param {Integer} minutes - The current audio minutes. 12242 */ 12243 function syncPlaylist(minutes) { 12244 /* 12245 Get all of the minute selectors 12246 */ 12247 var currentMinutePlaylistSelectors = document.querySelectorAll('.amplitude-current-minutes[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 12248 12249 /* 12250 Set the current minute selector's inner html to minutes passed in. 12251 */ 12252 for (var i = 0; i < currentMinutePlaylistSelectors.length; i++) { 12253 var songIndex = currentMinutePlaylistSelectors[i].getAttribute("data-amplitude-song-index"); 12254 12255 /* 12256 Updates the current minute selector for a global display. 12257 */ 12258 if (songIndex == null) { 12259 currentMinutePlaylistSelectors[i].innerHTML = minutes; 12260 } 12261 } 12262 } 12263 12264 /** 12265 * Syncs the current song minutes elements. 12266 * 12267 * @param {Integer} minutes - The current audio minutes. 12268 */ 12269 function syncSong(minutes) { 12270 if (_config2.default.active_playlist == null) { 12271 /* 12272 Get all of the minute selectors 12273 */ 12274 var currentMinuteSongSelectors = document.querySelectorAll('.amplitude-current-minutes[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 12275 12276 /* 12277 Set the current minute selector's inner html to minutes passed in. 12278 */ 12279 for (var i = 0; i < currentMinuteSongSelectors.length; i++) { 12280 var playlist = currentMinuteSongSelectors[i].getAttribute("data-amplitude-playlist"); 12281 12282 /* 12283 Updates the current minute selector for a global display. 12284 */ 12285 if (playlist == null) { 12286 currentMinuteSongSelectors[i].innerHTML = minutes; 12287 } 12288 } 12289 } 12290 } 12291 12292 /** 12293 * Syncs the current song in playlist minutes elements. 12294 * 12295 * @param {Integer} minutes - The current audio minutes. 12296 */ 12297 function syncSongInPlaylist(minutes) { 12298 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 12299 12300 /* 12301 Get all of the minute selectors 12302 */ 12303 var currentMinutePlaylistSongSelectors = document.querySelectorAll('.amplitude-current-minutes[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 12304 12305 /* 12306 Set the current minute selector's inner html to minutes passed in. 12307 */ 12308 for (var i = 0; i < currentMinutePlaylistSongSelectors.length; i++) { 12309 currentMinutePlaylistSongSelectors[i].innerHTML = minutes; 12310 } 12311 } 12312 12313 /** 12314 * Reset the current times. 12315 */ 12316 function resetTimes() { 12317 /* 12318 Gets the minute display elements 12319 */ 12320 var minuteSelectors = document.querySelectorAll(".amplitude-current-minutes"); 12321 12322 /* 12323 Iterates over all of the minute selectors and sets the inner HTML 12324 to 00. 12325 */ 12326 for (var i = 0; i < minuteSelectors.length; i++) { 12327 minuteSelectors[i].innerHTML = "00"; 12328 } 12329 } 12330 12331 /** 12332 * Returns the publically facing methods. 12333 */ 12334 return { 12335 sync: sync, 12336 resetTimes: resetTimes 12337 }; 12338}(); /** 12339 * Imports the config module 12340 * @module config 12341 */ 12342exports.default = CurrentMinuteElements; 12343module.exports = exports["default"]; 12344 12345/***/ }), 12346/* 52 */ 12347/***/ (function(module, exports, __webpack_require__) { 12348 12349"use strict"; 12350 12351 12352Object.defineProperty(exports, "__esModule", { 12353 value: true 12354}); 12355 12356var _config = __webpack_require__(0); 12357 12358var _config2 = _interopRequireDefault(_config); 12359 12360function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 12361 12362/** 12363 * Handles all of the current time seconds elements. 12364 * 12365 * @module visual/time/CurrentSecondElements 12366 */ 12367var CurrentSecondElements = function () { 12368 /** 12369 * Syncs the current seconds elements. 12370 * 12371 * @param {Integer} seconds - The current audio seconds. 12372 */ 12373 function sync(seconds) { 12374 syncGlobal(seconds); 12375 syncPlaylist(seconds); 12376 syncSong(seconds); 12377 syncSongInPlaylist(seconds); 12378 } 12379 12380 /** 12381 * Syncs the global current seconds elements. 12382 * 12383 * @param {Integer} seconds - The current audio seconds. 12384 */ 12385 function syncGlobal(seconds) { 12386 /* 12387 Get all of the second selectors 12388 */ 12389 var currentSecondSelectors = document.querySelectorAll(".amplitude-current-seconds"); 12390 12391 /* 12392 Set the current second selector's inner html to seconds passed in. 12393 */ 12394 for (var i = 0; i < currentSecondSelectors.length; i++) { 12395 var playlist = currentSecondSelectors[i].getAttribute("data-amplitude-playlist"); 12396 var songIndex = currentSecondSelectors[i].getAttribute("data-amplitude-song-index"); 12397 12398 /* 12399 Updates the current second selector for a global display. 12400 */ 12401 if (playlist == null && songIndex == null) { 12402 currentSecondSelectors[i].innerHTML = seconds; 12403 } 12404 } 12405 } 12406 12407 /** 12408 * Syncs the playlist seconds elements. 12409 * 12410 * @param {Integer} seconds - The current audio seconds. 12411 */ 12412 function syncPlaylist(seconds) { 12413 /* 12414 Get all of the second selectors 12415 */ 12416 var currentSecondPlaylistSelectors = document.querySelectorAll('.amplitude-current-seconds[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 12417 12418 /* 12419 Set the current second selector's inner html to seconds passed in. 12420 */ 12421 for (var i = 0; i < currentSecondPlaylistSelectors.length; i++) { 12422 var songIndex = currentSecondPlaylistSelectors[i].getAttribute("data-amplitude-song-index"); 12423 12424 /* 12425 Updates the current second selector for a global display. 12426 */ 12427 if (songIndex == null) { 12428 currentSecondPlaylistSelectors[i].innerHTML = seconds; 12429 } 12430 } 12431 } 12432 12433 /** 12434 * Syncs the current song seconds elements. 12435 * 12436 * @param {Integer} seconds - The current audio seconds. 12437 */ 12438 function syncSong(seconds) { 12439 if (_config2.default.active_playlist == null) { 12440 /* 12441 Get all of the second selectors 12442 */ 12443 var currentSecondSongSelectors = document.querySelectorAll('.amplitude-current-seconds[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 12444 12445 /* 12446 Set the current second selector's inner html to seconds passed in. 12447 */ 12448 for (var i = 0; i < currentSecondSongSelectors.length; i++) { 12449 var playlist = currentSecondSongSelectors[i].getAttribute("data-amplitude-playlist"); 12450 12451 /* 12452 Updates the current second selector for a global display. 12453 */ 12454 if (playlist == null) { 12455 currentSecondSongSelectors[i].innerHTML = seconds; 12456 } 12457 } 12458 } 12459 } 12460 12461 /** 12462 * Syncs the current song in playlist seconds elements. 12463 * 12464 * @param {Integer} seconds - The current audio seconds. 12465 */ 12466 function syncSongInPlaylist(seconds) { 12467 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 12468 /* 12469 Get all of the second selectors 12470 */ 12471 var currentSecondPlaylistSongSelectors = document.querySelectorAll('.amplitude-current-seconds[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 12472 12473 /* 12474 Set the current second selector's inner html to seconds passed in. 12475 */ 12476 for (var i = 0; i < currentSecondPlaylistSongSelectors.length; i++) { 12477 currentSecondPlaylistSongSelectors[i].innerHTML = seconds; 12478 } 12479 } 12480 12481 /** 12482 * Reset the current seconds elements. 12483 */ 12484 function resetTimes() { 12485 /* 12486 Gets the second display elements 12487 */ 12488 var secondSelectors = document.querySelectorAll(".amplitude-current-seconds"); 12489 12490 /* 12491 Iterates over all of the second selectors and sets the inner HTML 12492 to 00. 12493 */ 12494 for (var i = 0; i < secondSelectors.length; i++) { 12495 secondSelectors[i].innerHTML = "00"; 12496 } 12497 } 12498 12499 /** 12500 * Returns the publically facing methods. 12501 */ 12502 return { 12503 sync: sync, 12504 resetTimes: resetTimes 12505 }; 12506}(); /** 12507 * Imports the config module 12508 * @module config 12509 */ 12510exports.default = CurrentSecondElements; 12511module.exports = exports["default"]; 12512 12513/***/ }), 12514/* 53 */ 12515/***/ (function(module, exports, __webpack_require__) { 12516 12517"use strict"; 12518 12519 12520Object.defineProperty(exports, "__esModule", { 12521 value: true 12522}); 12523 12524var _config = __webpack_require__(0); 12525 12526var _config2 = _interopRequireDefault(_config); 12527 12528function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 12529 12530/** 12531 * These methods help sync visual time elements. 12532 * 12533 * @module visual/CurrentTimeElements 12534 */ 12535var CurrentTimeElements = function () { 12536 /** 12537 * Visually displays the current time on the screen. This is called on 12538 * time update for the current song. 12539 * 12540 * @access public 12541 * @param {object} currentTime - An object containing the current time for the song in seconds, minutes, and hours. 12542 */ 12543 function sync(currentTime) { 12544 /* 12545 Set current time display. 12546 */ 12547 syncGlobal(currentTime); 12548 syncPlaylist(currentTime); 12549 syncSong(currentTime); 12550 syncSongInPlaylist(currentTime); 12551 } 12552 12553 /** 12554 * Updates any elements that display the current time for the song. This 12555 * is a computed field that will be commonly used. 12556 * 12557 * @access public 12558 * @param {object} time - A json object conaining the parts for the current time for the song. 12559 */ 12560 function syncGlobal(time) { 12561 /* 12562 Get all of the time selectors. 12563 */ 12564 var currentTimeSelectors = document.querySelectorAll(".amplitude-current-time"); 12565 12566 /* 12567 Set the time selector's inner html to the current time for the song. The current 12568 time is computed by joining minutes and seconds. 12569 */ 12570 var timeText = time.minutes + ":" + time.seconds; 12571 12572 if (time.hours > 0) { 12573 timeText = time.hours + ":" + timeText; 12574 } 12575 12576 for (var i = 0; i < currentTimeSelectors.length; i++) { 12577 var playlist = currentTimeSelectors[i].getAttribute("data-amplitude-playlist"); 12578 var songIndex = currentTimeSelectors[i].getAttribute("data-amplitude-song-index"); 12579 12580 if (playlist == null && songIndex == null) { 12581 currentTimeSelectors[i].innerHTML = timeText; 12582 } 12583 } 12584 } 12585 12586 /** 12587 * Updates any elements that display the current time for the song. This 12588 * is a computed field that will be commonly used. 12589 * 12590 * @access public 12591 * @param {object} time - A json object conaining the parts for the current time for the song. 12592 */ 12593 function syncPlaylist(time) { 12594 /* 12595 Get all of the time selectors. 12596 */ 12597 var currentTimeSelectors = document.querySelectorAll('.amplitude-current-time[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 12598 12599 /* 12600 Set the time selector's inner html to the current time for the song. The current 12601 time is computed by joining minutes and seconds. 12602 */ 12603 var timeText = time.minutes + ":" + time.seconds; 12604 12605 if (time.hours > 0) { 12606 timeText = time.hours + ":" + timeText; 12607 } 12608 12609 for (var i = 0; i < currentTimeSelectors.length; i++) { 12610 var songIndex = currentTimeSelectors[i].getAttribute("data-amplitude-song-index"); 12611 12612 if (songIndex == null) { 12613 currentTimeSelectors[i].innerHTML = timeText; 12614 } 12615 } 12616 } 12617 12618 /** 12619 * Updates any elements that display the current time for the song. This 12620 * is a computed field that will be commonly used. 12621 * 12622 * @access public 12623 * @param {object} time - A json object conaining the parts for the current time for the song. 12624 */ 12625 function syncSong(time) { 12626 if (_config2.default.active_playlist == null) { 12627 /* 12628 Get all of the time selectors. 12629 */ 12630 var currentTimeSelectors = document.querySelectorAll('.amplitude-current-time[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 12631 12632 /* 12633 Set the time selector's inner html to the current time for the song. The current 12634 time is computed by joining minutes and seconds. 12635 */ 12636 var timeText = time.minutes + ":" + time.seconds; 12637 12638 if (time.hours > 0) { 12639 timeText = time.hours + ":" + timeText; 12640 } 12641 12642 for (var i = 0; i < currentTimeSelectors.length; i++) { 12643 var playlist = currentTimeSelectors[i].getAttribute("data-amplitude-playlist"); 12644 12645 if (playlist == null) { 12646 currentTimeSelectors[i].innerHTML = timeText; 12647 } 12648 } 12649 } 12650 } 12651 12652 /** 12653 * Updates any elements that display the current time for the song. This 12654 * is a computed field that will be commonly used. 12655 * 12656 * @access public 12657 * @param {object} time - A json object conaining the parts for the current time for the song. 12658 */ 12659 function syncSongInPlaylist(time) { 12660 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 12661 /* 12662 Get all of the time selectors. 12663 */ 12664 var currentTimeSelectors = document.querySelectorAll('.amplitude-current-time[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 12665 12666 /* 12667 Set the time selector's inner html to the current time for the song. The current 12668 time is computed by joining minutes and seconds. 12669 */ 12670 var timeText = time.minutes + ":" + time.seconds; 12671 12672 if (time.hours > 0) { 12673 timeText = time.hours + ":" + timeText; 12674 } 12675 12676 for (var i = 0; i < currentTimeSelectors.length; i++) { 12677 currentTimeSelectors[i].innerHTML = timeText; 12678 } 12679 } 12680 12681 /** 12682 * Resets the current time displays to 00:00 12683 * 12684 * @access public 12685 */ 12686 function resetTimes() { 12687 /* 12688 Gets the time selector display elements 12689 */ 12690 var timeSelectors = document.querySelectorAll(".amplitude-current-time"); 12691 12692 /* 12693 Iterates over all of the time selectors and sets the inner HTML 12694 to 00. 12695 */ 12696 for (var i = 0; i < timeSelectors.length; i++) { 12697 timeSelectors[i].innerHTML = "00:00"; 12698 } 12699 } 12700 12701 /** 12702 * Returns the publically facing methods 12703 */ 12704 return { 12705 sync: sync, 12706 resetTimes: resetTimes 12707 }; 12708}(); /** 12709 * Imports the config module 12710 * @module config 12711 */ 12712exports.default = CurrentTimeElements; 12713module.exports = exports["default"]; 12714 12715/***/ }), 12716/* 54 */ 12717/***/ (function(module, exports, __webpack_require__) { 12718 12719"use strict"; 12720 12721 12722Object.defineProperty(exports, "__esModule", { 12723 value: true 12724}); 12725 12726var _config = __webpack_require__(0); 12727 12728var _config2 = _interopRequireDefault(_config); 12729 12730function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 12731 12732/** 12733 * Handles all of the duration countdown elements. 12734 * 12735 * @module visual/time/DurationCountDownTimeElements. 12736 */ 12737var DurationCountDownTimeElements = function () { 12738 /** 12739 * Syncs all of the countdown time elements. 12740 * 12741 * @param {object} countDownTime - The current time of the audio. 12742 * @param {object} songDuration - The song duration of the audio. 12743 */ 12744 function sync(countDownTime, songDuration) { 12745 var timeRemaining = computeTimeRemaining(countDownTime, songDuration); 12746 12747 syncGlobal(timeRemaining); 12748 syncPlaylist(timeRemaining); 12749 syncSong(timeRemaining); 12750 syncSongInPlaylist(timeRemaining); 12751 } 12752 12753 /** 12754 * Syncs the global count down time elements. 12755 * 12756 * @param {string} timeRemaining - The time remaining for the audio. 12757 */ 12758 function syncGlobal(timeRemaining) { 12759 var durationTimeRemainingSelectors = document.querySelectorAll(".amplitude-time-remaining"); 12760 12761 for (var i = 0; i < durationTimeRemainingSelectors.length; i++) { 12762 var playlist = durationTimeRemainingSelectors[i].getAttribute("data-amplitude-playlist"); 12763 var songIndex = durationTimeRemainingSelectors[i].getAttribute("data-amplitude-song-index"); 12764 12765 if (playlist == null && songIndex == null) { 12766 durationTimeRemainingSelectors[i].innerHTML = timeRemaining; 12767 } 12768 } 12769 } 12770 12771 /** 12772 * Syncs the playlist count down time elements. 12773 * 12774 * @param {string} timeRemaining - The time remaining for the audio. 12775 */ 12776 function syncPlaylist(timeRemaining) { 12777 var durationTimeRemainingSelectors = document.querySelectorAll('.amplitude-time-remaining[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 12778 12779 for (var i = 0; i < durationTimeRemainingSelectors.length; i++) { 12780 var songIndex = durationTimeRemainingSelectors[i].getAttribute("data-amplitude-song-index"); 12781 12782 if (songIndex == null) { 12783 durationTimeRemainingSelectors[i].innerHTML = timeRemaining; 12784 } 12785 } 12786 } 12787 12788 /** 12789 * Syncs the song count down time elements. 12790 * 12791 * @param {string} timeRemaining - The time remaining for the audio. 12792 */ 12793 function syncSong(timeRemaining) { 12794 if (_config2.default.active_playlist == null) { 12795 var durationTimeRemainingSelectors = document.querySelectorAll('.amplitude-time-remaining[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 12796 12797 for (var i = 0; i < durationTimeRemainingSelectors.length; i++) { 12798 var playlist = durationTimeRemainingSelectors[i].getAttribute("data-amplitude-playlist"); 12799 12800 if (playlist == null) { 12801 durationTimeRemainingSelectors[i].innerHTML = timeRemaining; 12802 } 12803 } 12804 } 12805 } 12806 12807 /** 12808 * Syncs the song in playlist count down time elements. 12809 * 12810 * @param {string} timeRemaining - The time remaining for the audio. 12811 */ 12812 function syncSongInPlaylist(timeRemaining) { 12813 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 12814 12815 var durationTimeRemainingSelectors = document.querySelectorAll('.amplitude-time-remaining[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 12816 12817 for (var i = 0; i < durationTimeRemainingSelectors.length; i++) { 12818 durationTimeRemainingSelectors[i].innerHTML = timeRemaining; 12819 } 12820 } 12821 12822 /** 12823 * Resets the count down times. 12824 */ 12825 function resetTimes() { 12826 var durationTimeRemainingSelectors = document.querySelectorAll(".amplitude-time-remaining"); 12827 12828 for (var i = 0; i < durationTimeRemainingSelectors.length; i++) { 12829 durationTimeRemainingSelectors[i].innerHTML = "00"; 12830 } 12831 } 12832 12833 /** 12834 * Computes the time remaining for the audio. 12835 * 12836 * @param {object} currentTime - The current time of the audio. 12837 * @param {object} songDuration - The duration of the audio. 12838 */ 12839 function computeTimeRemaining(currentTime, songDuration) { 12840 var timeRemaining = "00:00"; 12841 12842 /* 12843 Initialize the total current seconds and total duration seconds 12844 */ 12845 var totalCurrentSeconds = parseInt(currentTime.seconds) + parseInt(currentTime.minutes) * 60 + parseInt(currentTime.hours) * 60 * 60; 12846 var totalDurationSeconds = parseInt(songDuration.seconds) + parseInt(songDuration.minutes) * 60 + parseInt(songDuration.hours) * 60 * 60; 12847 12848 /* 12849 If the two variables are numbers we continue the computing. 12850 */ 12851 if (!isNaN(totalCurrentSeconds) && !isNaN(totalDurationSeconds)) { 12852 /* 12853 Find the total remaining seconds. 12854 */ 12855 var timeRemainingTotalSeconds = totalDurationSeconds - totalCurrentSeconds; 12856 12857 var remainingHours = Math.floor(timeRemainingTotalSeconds / 3600); 12858 var remainingMinutes = Math.floor((timeRemainingTotalSeconds - remainingHours * 3600) / 60); 12859 var remainingSeconds = timeRemainingTotalSeconds - remainingHours * 3600 - remainingMinutes * 60; 12860 12861 timeRemaining = (remainingMinutes < 10 ? "0" + remainingMinutes : remainingMinutes) + ":" + (remainingSeconds < 10 ? "0" + remainingSeconds : remainingSeconds); 12862 12863 if (remainingHours > 0) { 12864 timeRemaining = remainingHours + ":" + timeRemaining; 12865 } 12866 } 12867 12868 return timeRemaining; 12869 } 12870 12871 /** 12872 * Returns the publically facing methods. 12873 */ 12874 return { 12875 sync: sync, 12876 resetTimes: resetTimes 12877 }; 12878}(); /** 12879 * Imports the config module 12880 * @module config 12881 */ 12882exports.default = DurationCountDownTimeElements; 12883module.exports = exports["default"]; 12884 12885/***/ }), 12886/* 55 */ 12887/***/ (function(module, exports, __webpack_require__) { 12888 12889"use strict"; 12890 12891 12892Object.defineProperty(exports, "__esModule", { 12893 value: true 12894}); 12895 12896var _config = __webpack_require__(0); 12897 12898var _config2 = _interopRequireDefault(_config); 12899 12900function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 12901 12902/** 12903 * Handles all of the duration hours elements. 12904 * 12905 * @module visual/time/DurationHourElements. 12906 */ 12907var DurationHourElements = function () { 12908 /** 12909 * Sync the duration hours elements. 12910 * 12911 * @param {Integer} hours - The duration hours for the audio. 12912 */ 12913 function sync(hours) { 12914 syncGlobal(hours); 12915 syncPlaylist(hours); 12916 syncSong(hours); 12917 syncSongInPlaylist(hours); 12918 } 12919 12920 /** 12921 * Syncs the global duration hours elements. 12922 * 12923 * @param {Integer} hours - the duration hours for the audio. 12924 */ 12925 function syncGlobal(hours) { 12926 var durationHourSelectors = document.querySelectorAll(".amplitude-duration-hours"); 12927 12928 for (var i = 0; i < durationHourSelectors.length; i++) { 12929 var playlist = durationHourSelectors[i].getAttribute("data-amplitude-playlist"); 12930 var songIndex = durationHourSelectors[i].getAttribute("data-amplitude-song-index"); 12931 12932 if (playlist == null && songIndex == null) { 12933 durationHourSelectors[i].innerHTML = hours; 12934 } 12935 } 12936 } 12937 12938 /** 12939 * Syncs the playlist duration hours for the audio. 12940 * 12941 * @param {Integer} hours - The duration hours for the audio. 12942 */ 12943 function syncPlaylist(hours) { 12944 var durationHourSelectors = document.querySelectorAll('.amplitude-duration-hours[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 12945 12946 for (var i = 0; i < durationHourSelectors.length; i++) { 12947 var songIndex = durationHourSelectors[i].getAttribute("data-amplitude-song-index"); 12948 12949 if (songIndex == null) { 12950 durationHourSelectors[i].innerHTML = hours; 12951 } 12952 } 12953 } 12954 12955 /** 12956 * Syncs the song duration hours. 12957 * 12958 * @param {Integer} hours - The duration hours for the audio. 12959 */ 12960 function syncSong(hours) { 12961 if (_config2.default.active_playlist == null) { 12962 var durationHourSelectors = document.querySelectorAll('.amplitude-duration-hours[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 12963 12964 for (var i = 0; i < durationHourSelectors.length; i++) { 12965 var playlist = durationHourSelectors[i].getAttribute("data-amplitude-playlist"); 12966 12967 if (playlist == null) { 12968 durationHourSelectors[i].innerHTML = hours; 12969 } 12970 } 12971 } 12972 } 12973 12974 /** 12975 * Syncs the song in playlist duration hours. 12976 * 12977 * @param {Integer} hours - The duration hours of the audio. 12978 */ 12979 function syncSongInPlaylist(hours) { 12980 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 12981 12982 var durationHourSelectors = document.querySelectorAll('.amplitude-duration-hours[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 12983 12984 for (var i = 0; i < durationHourSelectors.length; i++) { 12985 durationHourSelectors[i].innerHTML = hours; 12986 } 12987 } 12988 12989 /** 12990 * Resets the duration shours elements to '00' 12991 */ 12992 function resetTimes() { 12993 var durationHourSelectors = document.querySelectorAll(".amplitude-duration-hours"); 12994 12995 for (var i = 0; i < durationHourSelectors.length; i++) { 12996 durationHourSelectors[i].innerHTML = "00"; 12997 } 12998 } 12999 13000 /** 13001 * Returns the publically facing methods. 13002 */ 13003 return { 13004 sync: sync, 13005 resetTimes: resetTimes 13006 }; 13007}(); /** 13008 * Imports the config module 13009 * @module config 13010 */ 13011exports.default = DurationHourElements; 13012module.exports = exports["default"]; 13013 13014/***/ }), 13015/* 56 */ 13016/***/ (function(module, exports, __webpack_require__) { 13017 13018"use strict"; 13019 13020 13021Object.defineProperty(exports, "__esModule", { 13022 value: true 13023}); 13024 13025var _config = __webpack_require__(0); 13026 13027var _config2 = _interopRequireDefault(_config); 13028 13029function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13030 13031/** 13032 * Handles all of the duration minutes elements. 13033 * 13034 * @module visual/time/DurationMinuteElements. 13035 */ 13036var DurationMinuteElements = function () { 13037 /** 13038 * Sync the duration minutes elements. 13039 * 13040 * @param {Integer} minutes - The duration minutes for the audio. 13041 */ 13042 function sync(minutes) { 13043 syncGlobal(minutes); 13044 syncPlaylist(minutes); 13045 syncSong(minutes); 13046 syncSongInPlaylist(minutes); 13047 } 13048 13049 /** 13050 * Syncs the global duration minutes elements. 13051 * 13052 * @param {Integer} minutes - the duration minutes for the audio. 13053 */ 13054 function syncGlobal(minutes) { 13055 var durationMinuteSelectors = document.querySelectorAll(".amplitude-duration-minutes"); 13056 13057 for (var i = 0; i < durationMinuteSelectors.length; i++) { 13058 var playlist = durationMinuteSelectors[i].getAttribute("data-amplitude-playlist"); 13059 var songIndex = durationMinuteSelectors[i].getAttribute("data-amplitude-song-index"); 13060 13061 if (playlist == null && songIndex == null) { 13062 durationMinuteSelectors[i].innerHTML = minutes; 13063 } 13064 } 13065 } 13066 13067 /** 13068 * Syncs the playlist duration minutes for the audio. 13069 * 13070 * @param {Integer} minutes - The duration minutes for the audio. 13071 */ 13072 function syncPlaylist(minutes) { 13073 var durationMinuteSelectors = document.querySelectorAll('.amplitude-duration-minutes[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 13074 13075 for (var i = 0; i < durationMinuteSelectors.length; i++) { 13076 var songIndex = durationMinuteSelectors[i].getAttribute("data-amplitude-song-index"); 13077 13078 if (songIndex == null) { 13079 durationMinuteSelectors[i].innerHTML = minutes; 13080 } 13081 } 13082 } 13083 13084 /** 13085 * Syncs the song duration minutes. 13086 * 13087 * @param {Integer} minutes - The duration minutes for the audio. 13088 */ 13089 function syncSong(minutes) { 13090 if (_config2.default.active_playlist == null) { 13091 var durationMinuteSelectors = document.querySelectorAll('.amplitude-duration-minutes[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 13092 13093 for (var i = 0; i < durationMinuteSelectors.length; i++) { 13094 var playlist = durationMinuteSelectors[i].getAttribute("data-amplitude-playlist"); 13095 13096 if (playlist == null) { 13097 durationMinuteSelectors[i].innerHTML = minutes; 13098 } 13099 } 13100 } 13101 } 13102 13103 /** 13104 * Syncs the song in playlist duration minutes. 13105 * 13106 * @param {Integer} minutes - The duration minutes of the audio. 13107 */ 13108 function syncSongInPlaylist(minutes) { 13109 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 13110 13111 var durationMinuteSelectors = document.querySelectorAll('.amplitude-duration-minutes[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 13112 13113 for (var i = 0; i < durationMinuteSelectors.length; i++) { 13114 durationMinuteSelectors[i].innerHTML = minutes; 13115 } 13116 } 13117 13118 /** 13119 * Resets the duration minutes elements to '00' 13120 */ 13121 function resetTimes() { 13122 var durationMinuteSelectors = document.querySelectorAll(".amplitude-duration-minutes"); 13123 13124 for (var i = 0; i < durationMinuteSelectors.length; i++) { 13125 durationMinuteSelectors[i].innerHTML = "00"; 13126 } 13127 } 13128 13129 /** 13130 * Returns the publically facing methods. 13131 */ 13132 return { 13133 sync: sync, 13134 resetTimes: resetTimes 13135 }; 13136}(); /** 13137 * Imports the config module 13138 * @module config 13139 */ 13140exports.default = DurationMinuteElements; 13141module.exports = exports["default"]; 13142 13143/***/ }), 13144/* 57 */ 13145/***/ (function(module, exports, __webpack_require__) { 13146 13147"use strict"; 13148 13149 13150Object.defineProperty(exports, "__esModule", { 13151 value: true 13152}); 13153 13154var _config = __webpack_require__(0); 13155 13156var _config2 = _interopRequireDefault(_config); 13157 13158function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13159 13160/** 13161 * Handles all of the duration seconds elements. 13162 * 13163 * @module visual/time/DurationSecondElements. 13164 */ 13165var DurationSecondElements = function () { 13166 /** 13167 * Sync the duration seconds elements. 13168 * 13169 * @param {Integer} seconds - The duration seconds for the audio. 13170 */ 13171 function sync(seconds) { 13172 syncGlobal(seconds); 13173 syncPlaylist(seconds); 13174 syncSong(seconds); 13175 syncSongInPlaylist(seconds); 13176 } 13177 13178 /** 13179 * Syncs the global duration seconds elements. 13180 * 13181 * @param {Integer} seconds - the duration seconds for the audio. 13182 */ 13183 function syncGlobal(seconds) { 13184 var durationSecondSelectors = document.querySelectorAll(".amplitude-duration-seconds"); 13185 13186 for (var i = 0; i < durationSecondSelectors.length; i++) { 13187 var playlist = durationSecondSelectors[i].getAttribute("data-amplitude-playlist"); 13188 var songIndex = durationSecondSelectors[i].getAttribute("data-amplitude-song-index"); 13189 13190 if (playlist == null && songIndex == null) { 13191 durationSecondSelectors[i].innerHTML = seconds; 13192 } 13193 } 13194 } 13195 13196 /** 13197 * Syncs the playlist duration seconds for the audio. 13198 * 13199 * @param {Integer} seconds - The duration seconds for the audio. 13200 */ 13201 function syncPlaylist(seconds) { 13202 var durationSecondSelectors = document.querySelectorAll('.amplitude-duration-seconds[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 13203 13204 for (var i = 0; i < durationSecondSelectors.length; i++) { 13205 var songIndex = durationSecondSelectors[i].getAttribute("data-amplitude-song-index"); 13206 13207 if (songIndex == null) { 13208 durationSecondSelectors[i].innerHTML = seconds; 13209 } 13210 } 13211 } 13212 13213 /** 13214 * Syncs the song duration seconds. 13215 * 13216 * @param {Integer} seconds - The duration seconds for the audio. 13217 */ 13218 function syncSong(seconds) { 13219 if (_config2.default.active_playlist == null) { 13220 var durationSecondSelectors = document.querySelectorAll('.amplitude-duration-seconds[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 13221 13222 for (var i = 0; i < durationSecondSelectors.length; i++) { 13223 var playlist = durationSecondSelectors[i].getAttribute("data--amplitude-playlist"); 13224 13225 if (playlist == null) { 13226 durationSecondSelectors[i].innerHTML = seconds; 13227 } 13228 } 13229 } 13230 } 13231 13232 /** 13233 * Syncs the song in playlist duration seconds. 13234 * 13235 * @param {Integer} seconds - The duration seconds of the audio. 13236 */ 13237 function syncSongInPlaylist(seconds) { 13238 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 13239 13240 var durationSecondSelectors = document.querySelectorAll('.amplitude-duration-seconds[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 13241 13242 for (var i = 0; i < durationSecondSelectors.length; i++) { 13243 durationSecondSelectors[i].innerHTML = seconds; 13244 } 13245 } 13246 13247 /** 13248 * Resets the duration seconds elements to '00' 13249 */ 13250 function resetTimes() { 13251 var durationSecondSelectors = document.querySelectorAll(".amplitude-duration-seconds"); 13252 13253 for (var i = 0; i < durationSecondSelectors.length; i++) { 13254 durationSecondSelectors[i].innerHTML = "00"; 13255 } 13256 } 13257 13258 /** 13259 * Returns the publically facing methods. 13260 */ 13261 return { 13262 sync: sync, 13263 resetTimes: resetTimes 13264 }; 13265}(); /** 13266 * Imports the config module 13267 * @module config 13268 */ 13269exports.default = DurationSecondElements; 13270module.exports = exports["default"]; 13271 13272/***/ }), 13273/* 58 */ 13274/***/ (function(module, exports, __webpack_require__) { 13275 13276"use strict"; 13277 13278 13279Object.defineProperty(exports, "__esModule", { 13280 value: true 13281}); 13282 13283var _config = __webpack_require__(0); 13284 13285var _config2 = _interopRequireDefault(_config); 13286 13287function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13288 13289/** 13290 * Handles all of the duration time elements. 13291 * 13292 * @module visual/time/DurationTimeElements. 13293 */ 13294var DurationTimeElements = function () { 13295 /** 13296 * Syncs the duration time for all elements. 13297 * 13298 * @param {Object} durationTime - The object containing all of the song duration times. 13299 */ 13300 function sync(durationTime) { 13301 var durationText = computeDurationText(durationTime); 13302 13303 syncGlobal(durationText); 13304 syncPlaylist(durationText); 13305 syncSong(durationText); 13306 syncSongInPlaylist(durationText); 13307 } 13308 13309 /** 13310 * Sync the global song duration elements. 13311 * 13312 * @param {Object} durationText - The text for the song duration. 13313 */ 13314 function syncGlobal(durationText) { 13315 var durationTimeSelectors = document.querySelectorAll(".amplitude-duration-time"); 13316 13317 for (var i = 0; i < durationTimeSelectors.length; i++) { 13318 var playlist = durationTimeSelectors[i].getAttribute("data-amplitude-playlist"); 13319 var songIndex = durationTimeSelectors[i].getAttribute("data-amplitude-song-index"); 13320 13321 if (playlist == null && songIndex == null) { 13322 durationTimeSelectors[i].innerHTML = durationText; 13323 } 13324 } 13325 } 13326 13327 /** 13328 * Sync the playlist duration times. 13329 * 13330 * @param {Object} durationText - The text for the song duration. 13331 */ 13332 function syncPlaylist(durationText) { 13333 var durationTimeSelectors = document.querySelectorAll('.amplitude-duration-time[data-amplitude-playlist="' + _config2.default.active_playlist + '"]'); 13334 13335 for (var i = 0; i < durationTimeSelectors.length; i++) { 13336 var songIndex = durationTimeSelectors[i].getAttribute("data-amplitude-song-index"); 13337 13338 if (songIndex == null) { 13339 durationTimeSelectors[i].innerHTML = durationText; 13340 } 13341 } 13342 } 13343 13344 /** 13345 * Sync the song duration times. 13346 * 13347 * @param {Object} durationText - The text for the song duration. 13348 */ 13349 function syncSong(durationText) { 13350 if (_config2.default.active_playlist == null) { 13351 var durationTimeSelectors = document.querySelectorAll('.amplitude-duration-time[data-amplitude-song-index="' + _config2.default.active_index + '"]'); 13352 13353 for (var i = 0; i < durationTimeSelectors.length; i++) { 13354 var playlist = durationTimeSelectors[i].getAttribute("data-amplitude-playlist"); 13355 13356 if (playlist == null) { 13357 durationTimeSelectors[i].innerHTML = durationText; 13358 } 13359 } 13360 } 13361 } 13362 13363 /** 13364 * Sync the song in playlist duration times. 13365 * 13366 * @param {Object} durationText - An object containing the duration text. 13367 */ 13368 function syncSongInPlaylist(durationText) { 13369 var activePlaylistIndex = _config2.default.active_playlist != "" && _config2.default.active_playlist != null ? _config2.default.playlists[_config2.default.active_playlist].active_index : null; 13370 13371 var durationTimeSelectors = document.querySelectorAll('.amplitude-duration-time[data-amplitude-playlist="' + _config2.default.active_playlist + '"][data-amplitude-song-index="' + activePlaylistIndex + '"]'); 13372 13373 for (var i = 0; i < durationTimeSelectors.length; i++) { 13374 durationTimeSelectors[i].innerHTML = durationText; 13375 } 13376 } 13377 13378 /** 13379 * Resets all of the duration times to empty. 13380 */ 13381 function resetTimes() { 13382 var durationTimeSelectors = document.querySelectorAll(".amplitude-duration-time"); 13383 13384 for (var i = 0; i < durationTimeSelectors.length; i++) { 13385 durationTimeSelectors[i].innerHTML = "00:00"; 13386 } 13387 } 13388 13389 /** 13390 * Computes the duration text 13391 * 13392 * @param {Object} durationTime - An object containint the duration times. 13393 */ 13394 function computeDurationText(durationTime) { 13395 var durationText = "00:00"; 13396 13397 if (!isNaN(durationTime.minutes) && !isNaN(durationTime.seconds)) { 13398 durationText = durationTime.minutes + ":" + durationTime.seconds; 13399 if (!isNaN(durationTime.hours) && durationTime.hours > 0) { 13400 durationText = durationTime.hours + ":" + durationText; 13401 } 13402 } 13403 13404 return durationText; 13405 } 13406 13407 /** 13408 * Return publically accessible methods. 13409 */ 13410 return { 13411 sync: sync, 13412 resetTimes: resetTimes 13413 }; 13414}(); /** 13415 * Imports the config module 13416 * @module config 13417 */ 13418exports.default = DurationTimeElements; 13419module.exports = exports["default"]; 13420 13421/***/ }), 13422/* 59 */ 13423/***/ (function(module, exports) { 13424 13425module.exports = {"name":"amplitudejs","version":"5.3.2","description":"A JavaScript library that allows you to control the design of your media controls in your webpage -- not the browser. No dependencies (jQuery not required) https://521dimensions.com/open-source/amplitudejs","main":"dist/amplitude.js","devDependencies":{"babel-core":"^6.26.3","babel-loader":"^7.1.5","babel-plugin-add-module-exports":"0.2.1","babel-polyfill":"^6.26.0","babel-preset-es2015":"^6.18.0","husky":"^1.3.1","jest":"^23.6.0","prettier":"1.15.1","pretty-quick":"^1.11.1","watch":"^1.0.2","webpack":"^2.7.0"},"directories":{"doc":"docs"},"files":["dist"],"funding":{"type":"opencollective","url":"https://opencollective.com/amplitudejs"},"scripts":{"build":"node_modules/.bin/webpack","prettier":"npx pretty-quick","preversion":"npx pretty-quick && npm run test","postversion":"git push && git push --tags","test":"jest","version":"npm run build && git add -A dist"},"repository":{"type":"git","url":"git+https://github.com/521dimensions/amplitudejs.git"},"keywords":["webaudio","html5","javascript","audio-player"],"author":"521 Dimensions (https://521dimensions.com)","license":"MIT","bugs":{"url":"https://github.com/521dimensions/amplitudejs/issues"},"homepage":"https://github.com/521dimensions/amplitudejs#readme"} 13426 13427/***/ }) 13428/******/ ]); 13429}); 13430//# sourceMappingURL=amplitude.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.