var H5P = H5P || {}; /** * H5P audio module * * @external {jQuery} $ H5P.jQuery */ H5P.Audio = (function ($) { /** * @param {Object} params Options for this library. * @param {Number} id Content identifier. * @param {Object} extras Extras. * @returns {undefined} */ function C(params, id, extras) { H5P.EventDispatcher.call(this); this.contentId = id; this.params = params; this.extras = extras; this.toggleButtonEnabled = true; // Retrieve previous state if (extras && extras.previousState !== undefined) { this.oldTime = extras.previousState.currentTime; } this.params = $.extend({}, { playerMode: 'minimalistic', fitToWrapper: false, controls: true, autoplay: false, audioNotSupported: "Your browser does not support this audio", playAudio: "Play audio", pauseAudio: "Pause audio" }, params); // Required if e.g. used in CoursePresentation as area to click on if (this.params.playerMode === 'transparent') { this.params.fitToWrapper = true; } this.on('resize', this.resize, this); } C.prototype = Object.create(H5P.EventDispatcher.prototype); C.prototype.constructor = C; /** * Adds a minimalistic audio player with only "play" and "pause" functionality. * * @param {jQuery} $container Container for the player. * @param {boolean} transparentMode true: the player is only visible when hovering over it; false: player's UI always visible */ C.prototype.addMinimalAudioPlayer = function ($container, transparentMode) { var INNER_CONTAINER = 'h5p-audio-inner'; var AUDIO_BUTTON = 'h5p-audio-minimal-button'; var PLAY_BUTTON = 'h5p-audio-minimal-play'; var PLAY_BUTTON_PAUSED = 'h5p-audio-minimal-play-paused'; var PAUSE_BUTTON = 'h5p-audio-minimal-pause'; var self = this; this.$container = $container; self.$inner = $('
', { 'class': INNER_CONTAINER + (transparentMode ? ' h5p-audio-transparent' : '') }).appendTo($container); var audioButton = $('