text: /*! V1.3.1, © INA 2016 */
  /**
   * Copyright (c) 2015 Institut National de l'Audiovisuel, INA
   * This file is part of amalia.js
  
   * amalia.js is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  
   * Redistributions of source code, javascript and css minified versions
   * must retain the above copyright notice, this list of conditions and the following disclaimer.
  
   * Neither the name of the copyright holder nor the names of its
   * contributors may be used to endorse or promote products derived from
   * this software without specific prior written permission.
  
   * You should have received a copy of the GNU General Public License
   * along with amalia.js. If not, see <http://www.gnu.org/licenses/>
  
   *
   * amalia.js is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU General Public License for more details.
   */
  
  fr.ina.amalia.player.plugins.PluginBase.extend("fr.ina.amalia.player.plugins.WatermarkPlugin",{classCss:"ajs-plugin plugin-watermark",eventTypes:{}},{container:null,ratio:0,placement:"",placementList:["c","tl","tr","bl","br"],initialize:function(){this._super(),this.settings=$.extend({backgroundImageUrl:"",ratio:50,placement:"c",imageWidth:0,imageHeight:0,topOffet:45},this.settings.parameters||{}),""!==this.settings.backgroundImageUrl&&(this.setPlacement(this.settings.placement),this.container=$("<div>",{"class":this.Class.classCss}),this.pluginContainer.append(this.container),this.defineListeners())},defineListeners:function(){var a=this.mediaPlayer.getMediaPlayer();a.one(fr.ina.amalia.player.PlayerEventType.TIME_CHANGE,{self:this},this.onPluginReady),$(window).on("debouncedresize",{self:this},this.onWindowResize),null!==this.logger&&this.logger.trace(this.Class.fullName,"definePlayerListeners")},initializeOnLoadStart:function(){this.createWatermarkElement()},createWatermarkElement:function(){var a=$("<div>",{style:"background-image: url("+this.settings.backgroundImageUrl+");","class":"watermark"});this.container.append(a),this.updatePos()},updatePos:function(){var a=this.getVideoSize(),b=a.w,c=a.h,d=(this.container.width()-b)/2,e=(this.container.height()-c-this.settings.topOffet)/2;this.container.find(".watermark").css({width:b+"px",height:c+"px",top:e+"px",left:d+"px"}),this.updateImagePositionWithPlacement(),this.updateImageSize()},updateImageSize:function(){var a=this.getVideoSize(),b=a.w/this.settings.imageWidth,c=a.h/this.settings.imageHeight,d=Math.min(b,c);d*=this.settings.ratio/100;var e=d*this.settings.imageWidth,f=d*this.settings.imageHeight,g=this.container.find(".watermark");g.css("background-size",e+"px "+f+"px")},updateImagePositionWithPlacement:function(){var a=this.container.find(".watermark"),b="50%",c="50%";"tl"===this.placement?(b="0%",c="0%"):"tr"===this.placement?(b="100%",c="0%"):"bl"===this.placement?(b="0%",c="100%"):"br"===this.placement&&(b="100%",c="100%"),a.css("background-position",b+" "+c)},getVideoSize:function(){var a=this.mediaPlayer.getMediaPlayer(),b=a.get(0).videoHeight,c=a.get(0).videoWidth;0===b&&(b=a.height()),0===c&&(c=a.width());var d=a.width()/c,e=a.height()/b,f=Math.min(d,e);return{w:f*c,h:f*b}},getPosition:function(){return this.placement},setPlacement:function(a){-1===$.inArray(a,this.placementList)?this.placement=this.placementList[0].toString():this.placement=a.toString()},onPluginReady:function(a){a.data.self.initializeOnLoadStart()},onWindowResize:function(a){a.data.self.updatePos()}});