/* * Acorn Media Player - jQuery plugin 1.6 * * Copyright (C) 2012 Ionut Cristian Colceriu * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * www.ghinda.net * contact@ghinda.net * */ (function($) { $.fn.acornMediaPlayer = function(options) { /* * Define default plugin options */ var defaults = { theme: 'access', nativeSliders: false, volumeSlider: 'horizontal', captionsOn: false }; options = $.extend(defaults, options); /* * Function for generating a unique identifier using the current date and time * Used for generating an ID for the media elmenet when none is available */ var uniqueID = function() { var currentDate = new Date(); return currentDate.getTime(); }; /* * Detect support for localStorage */ function supports_local_storage() { try { return 'localStorage' in window && window.localStorage !== null; } catch(e){ return false; } } /* * Get the volume value from localStorage * If no value is present, define as maximum */ var volume = (supports_local_storage) ? localStorage.getItem('acornvolume') : 1; if(!volume) { volume = 1; } /* * Main plugin function * It will be called on each element in the matched set */ var acornPlayer = function() { // set the acorn object, will contain the needed DOM nodes and others var acorn = { $self: $(this) }; var loadedMetadata; // Is the metadata loaded var seeking; // The user is seeking the media var wasPlaying; // Media was playing when the seeking started var fullscreenMode; // The media is in fullscreen mode var captionsActive; // Captions are active /* Define all the texts used * This makes it easier to maintain, make translations, etc. */ var text = { play: 'Play', playTitle: 'Start the playback', pause: 'Pause', pauseTitle: 'Pause the playback', mute: 'Mute', unmute: 'Unmute', fullscreen: 'Fullscreen', fullscreenTitle: 'Toggle fullscreen mode', swap: 'Swap', swapTitle: 'Toggle video and presention swap', volumeTitle: 'Volume control', seekTitle: 'Video seek control', captions: 'Captions', captionsTitle: 'Show captions', captionsChoose: 'Choose caption', transcript: 'Transcript', transcriptTitle: 'Show transcript' }; // main wrapper element var $wrapper = $('
').addClass(options.theme); /* * Define attribute tabindex on the main element to make it readchable by keyboard * Useful when "aria-describedby" is present * * It makes more sense for screen reader users to first reach the actual