<commit_before>package ru.kutu.grindplayer.views.mediators {
	
	import org.osmf.events.MetadataEvent;
	import org.osmf.media.MediaElement;
	import org.osmf.net.StreamType;
	
	import ru.kutu.grind.views.mediators.ScrubBarBaseMediator;
	
	public class ScrubBarMediator extends ScrubBarBaseMediator {
		
		private var isAdvertisement:Boolean;
		private var hideScrubBarWhileAdvertisement:Boolean;
		
		override protected function processMediaElementChange(oldMediaElement:MediaElement):void {
			super.processMediaElementChange(oldMediaElement);
			if (oldMediaElement) {
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
			if (media) {
				media.metadata.addEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
		}
		
		override protected function updateEnabled():void {
			view.enabled = isStartPlaying && !isAdvertisement;
			view.visible = streamType != StreamType.LIVE && !hideScrubBarWhileAdvertisement;
		}
		
		private function onMediaMetadataChange(event:MetadataEvent):void {
			if (event.key != "Advertisement") return;
			isAdvertisement = event.type != MetadataEvent.VALUE_REMOVE;
			hideScrubBarWhileAdvertisement = false;
			if (event.value && event.value is Array) {
				for each (var item:Object in event.value) {
					if ("hideScrubBarWhilePlayingAd" in item && item.hideScrubBarWhilePlayingAd) {
						hideScrubBarWhileAdvertisement = true;
						break;
					}
				}
			}
			updateEnabled();
		}
		
	}
	
}<commit_msg>remove disabling scrub bar on ads<commit_after>package ru.kutu.grindplayer.views.mediators {
	
	import org.osmf.events.MetadataEvent;
	import org.osmf.media.MediaElement;
	import org.osmf.net.StreamType;
	
	import ru.kutu.grind.views.mediators.ScrubBarBaseMediator;
	
	public class ScrubBarMediator extends ScrubBarBaseMediator {
		
		private var hideScrubBarWhileAdvertisement:Boolean;
		
		override protected function processMediaElementChange(oldMediaElement:MediaElement):void {
			super.processMediaElementChange(oldMediaElement);
			if (oldMediaElement) {
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
			if (media) {
				media.metadata.addEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
		}
		
		override protected function updateEnabled():void {
			view.enabled = isStartPlaying;
			view.visible = streamType != StreamType.LIVE && !hideScrubBarWhileAdvertisement;
		}
		
		private function onMediaMetadataChange(event:MetadataEvent):void {
			if (event.key != "Advertisement") return;
			hideScrubBarWhileAdvertisement = false;
			if (event.value && event.value is Array) {
				for each (var item:Object in event.value) {
					if ("hideScrubBarWhilePlayingAd" in item && item.hideScrubBarWhilePlayingAd) {
						hideScrubBarWhileAdvertisement = true;
						break;
					}
				}
			}
			updateEnabled();
		}
		
	}
	
}
{'fraction_non_alphanumeric': 0.08665937670858392, 'fraction_numerical': 0.0, 'mean_word_length': 5.191201353637902, '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': '7057507', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1011, 'n_words': 168}