{"size": 4548, "ext": "js", "max_stars_repo_path": "flowplayer.audio.js", "max_stars_repo_name": "flowplayer/flowplayer-audio", "max_stars_repo_stars_event_min_datetime": "2016-09-05T13:29:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-11T03:58:25.000Z", "max_issues_repo_path": "flowplayer.audio.js", "max_issues_repo_name": "flowplayer/flowplayer-audio", "max_issues_repo_issues_event_min_datetime": "2016-09-12T16:23:14.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-11T10:52:09.000Z", "max_forks_repo_path": "flowplayer.audio.js", "max_forks_repo_name": "flowplayer/flowplayer-audio", "max_forks_repo_forks_event_min_datetime": "2017-09-21T20:23:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-08T19:24:34.000Z"}
{"max_stars_count": 6, "max_issues_count": 6, "max_forks_count": 3, "avg_line_length": 38.8717948718, "max_line_length": 113, "alphanum_fraction": 0.4503078276}
/*jslint browser: true, node: true */
/*global window */

/*!

   Audio plugin for Flowplayer HTML5

   Copyright (c) 2016-2017, Flowplayer Drive Oy

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   Requires Flowplayer HTML5 version 6.x or greater
   $GIT_DESC$

*/
(function () {
    "use strict";
    var extension = function (flowplayer) {

        flowplayer(function (api, root) {
            var conf = flowplayer.extend(api.conf, api.conf.clip),
                common = flowplayer.common;

            if (conf.audioOnly || common.hasClass(root, "is-audio-only")) {
                var bean = flowplayer.bean,
                    coreV6 = flowplayer.version.indexOf("6.") === 0,
                    controls = common.find(".fp-controls", root)[0],
                    timeline = common.find(".fp-timeline", root)[0],
                    bgcolor = "background-color",
                    removalClasses = coreV6
                        ? ["fp-embed", "fp-fullscreen", "fp-title"]
                        : ["fp-pause", "fp-play", "fp-speed-flash"],
                    audioOnlyClasses = ["is-audio-only-7x", "is-audio-only", "is-mouseover"];


                if (coreV6) {
                    audioOnlyClasses = audioOnlyClasses.slice(1).concat(["fixed-controls", "play-button"]);
                }

                removalClasses.concat(["fp-ratio", "fp-help", "fp-speed", "fp-waiting"]).forEach(function (cls) {
                    common.find("." + cls, root).forEach(common.removeNode);
                });

                bean.off(root, "mouseenter");
                bean.off(root, "mouseleave");

                flowplayer.extend(api.conf, {
                    fullscreen: false,
                    ratio: false,
                    tooltip: false
                });

                audioOnlyClasses.forEach(function (cls) {
                    common.addClass(root, cls);
                });
                common.removeClass(root, "is-mouseout");
                if (coreV6) {
                    common.css(root, "margin-bottom", common.css(controls, "height"));
                } else {
                    if (/^(transparent|rgba\(0,\ 0,\ 0,\ 0\))$/.test(common.css(controls, bgcolor))) {
                        common.css(controls, bgcolor, "#bbb");
                    }
                    // make room for timestamp
                    common.css(root, "height", (common.height(controls) + 30) + "px");
                    common.css(root, "margin-top", "-30px");
                }

                if (!coreV6) {
                    bean.on(common.find(".fp-ui", root)[0], "click", function (e) {
                        if (common.hasClass(e.target, "fp-ui")) {
                            e.stopPropagation();
                        }
                    });
                    api.on("load.audioonly", function () {
                        // reveal timeline
                        common.css(timeline, bgcolor, "");
                    });
                }
                api.on("unload.audioonly", function () {
                    common.find(".fp-elapsed", root)[0].innerHTML = "00:00";
                    if (!coreV6) {
                        // do not show timeline in splash state
                        common.css(timeline, bgcolor, common.css(controls, bgcolor));
                    }
                });

            } else {
                var playerElem = common.find(".fp-player", root)[0],
                    removeAudioStyling = function () {
                        common.removeClass(root, "is-audio");
                        common.css(playerElem, "background-image", "");
                    };

                api.on("ready.audio", function (_e, _api, media) {
                    if (media.audio || (!media.index && conf.audio)) {
                        var coverImage = (media && media.coverImage) || (!media.index && conf.coverImage);

                        common.addClass(root, "is-audio");
                        if (coverImage) {
                            common.css(playerElem, "background-image", "url(" + coverImage + ")");
                        }
                    } else {
                        removeAudioStyling();
                    }

                }).on("unload.audio", removeAudioStyling);
            }
        });
    };
    if (typeof module === 'object' && module.exports) {
        module.exports = extension;
    } else if (window.flowplayer) {
        extension(window.flowplayer);
    }
}());
