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