<commit_before>( function( mw, $ , Hls ) {"use strict";

	//Currently use native support when available, e.g. Safari desktop and Edge
	if (Hls.isSupported() && !mw.isDesktopSafari() && !mw.isEdge() && !mw.getConfig("disableHLSOnJs")) {
		// Add HLS Logic player:
		//Force HLS streamer type
		mw.setConfig("streamerType", "hls");
		var config = mw.config.get("KalturaSupport.PlayerConfig");
		config.vars.streamerType = "hls";
		mw.config.set("KalturaSupport.PlayerConfig", config);
		var orig_supportsFlash = mw.supportsFlash;
		mw.supportsFlash = function () {
			return false;
		};
		$(mw).bind('EmbedPlayerUpdateMediaPlayers', function (event, mediaPlayers) {
			if (Hls.isSupported()) {
				//application/vnd.apple.mpegurl
				var hlsPlayer = new mw.MediaPlayer('hlsPlayer', ['video/h264', 'video/mp4', 'application/vnd.apple.mpegurl'], 'Native');
				mediaPlayers.addPlayer(hlsPlayer);
				mw.EmbedTypes.mediaPlayers.setMIMETypePlayers('application/vnd.apple.mpegurl', 'Native');
			}
		});

		var hlsjs = mw.KBasePlugin.extend({

			defaultConfig: {
				options: {
					//debug:true
					liveSyncDurationCount : 3,
					liveMaxLatencyDurationCount : 6
				},
				hlsLogs: false
			},

			/** @type {Number} */
			mediaErrorRecoveryCounter: 0,
			playerErrorRecoveryCounter: 0,

			debugInfoInterval: 4,
			debugInfoCounter:0,

			/** type {boolean} */
			LoadHLS: false,
			/** type {boolean} */
			loaded: false,
			/** type {boolean} */
			isLevelSwitching: false,
			/** type {Number} */
			levelIndex: -1,
			version: "v0.5.23",

			/**
			 * Check is HLS is supported
			 * @returns {boolean}
			 */
			isSafeEnviornment: function () {
				return Hls.isSupported();
			},
			/**
			 * Setup the HLS playback engine wrapper with supplied config options
			 */
			setup: function () {
				this.log( "version: " + Hls.version ? Hls.version : this.version );
				mw.setConfig('isHLS_JS', true);
				this.addBindings();
			},
			/**
			 *
			 */
			addBindings: function () {
				this.bind("onSelectSource", this.checkIfHLSNeeded.bind(this));
				this.bind("playerReady", this.initHls.bind(this));
				this.bind("onChangeMedia", this.clean.bind(this));
				this.bind("onLiveOffSynchChanged", this.onLiveOffSyncChanged.bind(this));
				if( mw.getConfig("hlsLogs") ) {
					this.bind("monitorEvent", this.monitorDebugInfo.bind(this));
				}
			},
			/**
			 * Check if HLS engine is required, e.g. sources contain HLS source
			 * @param event
			 * @param sources
			 */
			checkIfHLSNeeded: function (event, sources) {
				var _this = this;
				//Check if sources contain HLS source, if so then raise a flag to init the player
				$.each(sources, function (index, item) {
					if (item.mimeType === "application/vnd.apple.mpegurl") {
						_this.getPlayer().mediaElement.selectedSource = item;
						_this.LoadHLS = true;
					}
				});
			},
			/**
			 * Clean method
			 */
			clean: function () {
				this.log("Clean");
				if (this.LoadHLS && this.loaded) {
					this.LoadHLS = false;
					this.loaded = false;
					this.unRegisterHlsEvents();
					this.restorePlayerMethods();
					this.hls.detachMedia();
					this.hls.destroy();
					this.hls = null;
				}
			},
			/**
			 * Register the playback events and attach the playback engine to the video element
			 */
			initHls: function () {
				if (this.LoadHLS && !this.loaded) {
					this.log("Init");
					//Set streamerType to hls
					this.embedPlayer.streamerType = 'hls';
					//Init the HLS playback engine
					this.hls = new Hls(this.getConfig("options"));

					this.loaded = true;
					//Reset the error recovery counter
					this.mediaErrorRecoveryCounter = 0;
					//Disable update of video source tag, MSE uses blob urls!
					this.getPlayer().skipUpdateSource = true;<commit_msg>FEC-5898 #comment Do not select HLS source explicitly but by priority (#2941)<commit_after>( function( mw, $ , Hls ) {"use strict";

	//Currently use native support when available, e.g. Safari desktop and Edge
	if (Hls.isSupported() && !mw.isDesktopSafari() && !mw.isEdge() && !mw.getConfig("disableHLSOnJs")) {
		// Add HLS Logic player:
		//Force HLS streamer type
		mw.setConfig("streamerType", "hls");
		var config = mw.config.get("KalturaSupport.PlayerConfig");
		config.vars.streamerType = "hls";
		mw.config.set("KalturaSupport.PlayerConfig", config);
		var orig_supportsFlash = mw.supportsFlash;
		mw.supportsFlash = function () {
			return false;
		};
		$(mw).bind('EmbedPlayerUpdateMediaPlayers', function (event, mediaPlayers) {
			if (Hls.isSupported()) {
				//application/vnd.apple.mpegurl
				var hlsPlayer = new mw.MediaPlayer('hlsPlayer', ['video/h264', 'video/mp4', 'application/vnd.apple.mpegurl'], 'Native');
				mediaPlayers.addPlayer(hlsPlayer);
				mw.EmbedTypes.mediaPlayers.setMIMETypePlayers('application/vnd.apple.mpegurl', 'Native');
			}
		});

		var hlsjs = mw.KBasePlugin.extend({

			defaultConfig: {
				options: {
					//debug:true
					liveSyncDurationCount : 3,
					liveMaxLatencyDurationCount : 6
				},
				hlsLogs: false
			},

			/** @type {Number} */
			mediaErrorRecoveryCounter: 0,
			playerErrorRecoveryCounter: 0,

			debugInfoInterval: 4,
			debugInfoCounter:0,

			/** type {boolean} */
			loaded: false,
			/** type {boolean} */
			isLevelSwitching: false,
			/** type {Number} */
			levelIndex: -1,
			version: "v0.5.23",

			/**
			 * Check is HLS is supported
			 * @returns {boolean}
			 */
			isSafeEnviornment: function () {
				return Hls.isSupported();
			},
			/**
			 * Setup the HLS playback engine wrapper with supplied config options
			 */
			setup: function () {
				this.log( "version: " + Hls.version ? Hls.version : this.version );
				mw.setConfig('isHLS_JS', true);
				this.addBindings();
			},
			/**
			 *
			 */
			addBindings: function () {
				this.bind("playerReady", this.initHls.bind(this));
				this.bind("onChangeMedia", this.clean.bind(this));
				this.bind("onLiveOffSynchChanged", this.onLiveOffSyncChanged.bind(this));
				if( mw.getConfig("hlsLogs") ) {
					this.bind("monitorEvent", this.monitorDebugInfo.bind(this));
				}
			},
			/**
			 * Clean method
			 */
			clean: function () {
				this.log("Clean");
				if (this.loaded) {
					this.loaded = false;
					this.unRegisterHlsEvents();
					this.restorePlayerMethods();
					this.hls.detachMedia();
					this.hls.destroy();
					this.hls = null;
				}
			},
			/**
			 * Register the playback events and attach the playback engine to the video element
			 */
			initHls: function () {
				if (!this.loaded) {
					this.log("Init");
					//Set streamerType to hls
					this.embedPlayer.streamerType = 'hls';
					//Init the HLS playback engine
					this.hls = new Hls(this.getConfig("options"));

					this.loaded = true;
					//Reset the error recovery counter
					this.mediaErrorRecoveryCounter = 0;
					//Disable update of video source tag, MSE uses blob urls!
					this.getPlayer().skipUpdateSource = true;
{'fraction_non_alphanumeric': 0.14684606481481483, 'fraction_numerical': 0.005787037037037037, 'mean_word_length': 3.0403272939801287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5503647', 'n_tokens_mistral': 2881, 'n_tokens_neox': 2224, 'n_words': 489}