{"name":"OncePlayerJS","key":"onceplayer","version":"1.0.1","instructions":"This is an HTML5 audio player that will only play the audio file it manages once.","showatto":"0","showplayers":"1","requirecss":"//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css","requirejs":"","shim":"","defaults":"canpause=0,pause=fa-stop,play=fa-play,over=fa-minus,playing=fa-circle-o-notch","amd":"1","body":"<div id='@@AUTOID@@_container' class='poodll_onceplayer'>\n<button type='button'  id='@@AUTOID@@' class='poodll_onceplayer_button'><audio id='@@AUTOID@@_player' class=\"onceplayerjs nomediaplugin\" src=\"@@VIDEOURL@@\"></audio><i class=\"fa fa-play fa-2x\" aria-hidden=\"true\"></i></button>\n<!-- div id='@@AUTOID@@_slider' class='poodll_onceplayer_slider' -->\n<div id='@@AUTOID@@_time' class='poodll_onceplayer_time'></div>\n<div id='@@AUTOID@@_state' class='poodll_onceplayer_state'></div>\n</div>","bodyend":"","script":"//time display function\nfunction poodll_op_sec2time(seconds){\n    var date = new Date(null);\n    date.setSeconds(seconds); \n    return date.toISOString().substr(11, 8);\n}\nfunction poodll_op_fetchtime(theplayer){\n     var a_currenttime= isNaN(theplayer[0].currentTime) ? 0 : theplayer[0].currentTime;\n     var a_duration= isNaN(theplayer[0].duration) ? 0 : theplayer[0].duration;\n     var currenttime = poodll_op_sec2time(Math.floor(a_currenttime));\n     var totaltime = poodll_op_sec2time(Math.floor(a_duration)); \n     var displaytime = currenttime + ' / ' +  totaltime;\n    return displaytime;\n}\n\n//get our player\nvar aplayer = $('#' + @@AUTOID@@).children().first();\nvar fa = $('#' + @@AUTOID@@ + ' .fa');\nvar thestate =$('#' + @@AUTOID@@ + '_state'); \nvar thetime = $('#' + @@AUTOID@@ + '_time'); \n\n//The timer display\naplayer.on('timeupdate',function(e){\n var displaytime = poodll_op_fetchtime(aplayer)\n thetime.text(displaytime);\n});\n\n//show current time\n thetime.text(poodll_op_fetchtime(aplayer));\n\n//set status\nthestate.text('- ready -');\n\n//set player ended event\naplayer[0].addEventListener('ended', function(){\n    aplayer[0].pause();\n    $(fa).removeClass(@@playing@@);\n    $(fa).removeClass('fa-spin');\n    $(fa).removeClass(@@play@@);\n    $(fa).addClass(@@over@@);\n   thestate.text('- finished -');\n});\n\n//player clicked event\n$('#' + @@AUTOID@@).click(function(){\n  if(aplayer[0].ended){\n    return;\n}\n  if(!aplayer[0].paused && @@canpause@@ != '0'){\n     aplayer[0].pause();\n    thestate.text('- paused -');\n     $(fa).removeClass(@@playing@@);\n     $(fa).removeClass('fa-spin');\n     $(fa).addClass(@@play@@);\n   }else if(aplayer[0].paused || !aplayer[0].playing){\n     aplayer[0].play();\n     thestate.text('- playing -');\n     $(fa).removeClass(@@play@@);\n     $(fa).addClass(@@playing@@);\n     $(fa).addClass('fa-spin');\n   }\n});\n\naplayer.bind('durationchange',function(){thetime.text(poodll_op_fetchtime(aplayer));});\n\nvar is_https = M.cfg.wwwroot.indexOf('https:')==0;\nvar is_ios = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;\nif(is_https && is_ios){\n var xhr = new XMLHttpRequest();\n xhr.onreadystatechange = function(){\n    if (this.readyState == 4 && this.status == 200){\n        var url = window.URL || window.webkitURL;\n        aplayer[0].src = url.createObjectURL(this.response);\n    }\n }\n xhr.open('GET', @@VIDEOURL@@);\n xhr.responseType = 'blob';\n xhr.send();  \n}\n\n//the volume slider\n/*\n$('#' + @@AUTOID@@ + '_slider').slider({\norientation: 'horizontal',\nvalue: aplayer[0].volume,\nmin: 0,\nmax: 1,\nrange: 'min',\nanimate: true,\nstep: 0.1,\nslide: function(e,ui){\n aplayer[0].volume = ui.value;\n}\n});\n*/\n","style":"/* //code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css */\n.poodll_onceplayer{\n border: 3px solid blue;\n/* Safari 3-4, iOS 1-3.2, Android 1.6- */\n  -webkit-border-radius: 12px; \n  /* Firefox 1-3.6 */\n  -moz-border-radius: 12px; \n  /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */\n  border-radius: 12px; \nbackground-color: white;\n width: 200px;\n height: 110px;\ntext-align: center;\n}\n.poodll_onceplayer_time{\n padding: 3px;\n}\n.poodll_onceplayer_button{\n border: 1px solid;\n width: 50px;\n height: 42px;\n margin-top: 5px;\n margin-top: 5px;\n}","dataset":"","datasetvars":"","alternate":"<audio id=\"@@AUTOID@@\" controls=\"controls\" class=\"nomediaplugin\">\n  <source src=\"@@VIDEOURL@@\" type=\"audio/mpeg\">\n</audio>","alternateend":""}