<commit_before>'use strict';

angular.module('streama').directive('streamaVideoPlayer', [
  'uploadService', 'localStorageService', '$timeout', 'playerService', '$http',
  function (uploadService, localStorageService, $timeout, playerService, $http) {

    return {
      restrict: 'AE',
      templateUrl: '/streama/streama-video-player.htm',
      scope: {
        options: '='
      },

      link: function ($scope, $elem, $attrs) {
				var video;
        var controlDisplayTimeout;
        var overlayTimeout;
        var volumeChangeTimeout;
        var currentTimeChangeTimeout;
				var currEpisode = null;
        var skippingDuration = 20;  //Skipping duration for holding an arrow key to left or right.
        var longSkippingDuration = 60; //Skipping duration for holding ctrl + arrow key.
        var skipIntro = true;         //Userflag intro should be skipped
        var minimizeOnOutro = true;   //Userflag skip to next episode on outro
				var videoSrc = $scope.options.videoSrc.toString();

				$scope.showControls = showControls;
				$scope.toggleSelectEpisodes = toggleSelectEpisodes;
				$scope.createNewPlayerSession = createNewPlayerSession;
        $scope.toggleTextTrack = toggleTextTrack;
        $scope.playerVolumeToggle = playerVolumeToggle;
				$scope.play = play;
				$scope.pause = pause;
				$scope.closeVideo = closeVideo;
				$scope.clickVideo = clickVideo;
				$scope.fullScreen = toggleFullScreen;
				$scope.next = $scope.options.onNext;
				$scope.isInitialized = false;
				$scope.loading = true;
				$scope.initialPlay = false;

				$http.head(videoSrc)
          .success(function(){
            initDirective();
          })
          .error(function(data, status) {
            if(status == 406){
              $scope.options.onError('FILE_IN_FS_NOT_FOUND');
            }
          });

				function initDirective() {
					$scope.isInitialized = true;

					$elem.addClass('nocursor');

					initMouseWheel();
					initMousetrap();
					initExternalTriggers();
					initIsMobile();
					$scope.volumeLevel = localStorageService.get('volumeLevel') || 5;
					$scope.$on('$destroy', onDirectiveDestroy);
					$scope.$on('$stateChangeSuccess', onStateChangeSuccess);

					$timeout(function () {
						var $video = $elem.find('video');
						$video.bind("contextmenu",function(){return false;});
						video = $video[0];
						video.oncanplay = oncanplay;
						video.onwaiting = onwaiting;
						video.onplaying = onplaying;
						video.onerror = onerror;
						video.ontimeupdate = ontimeupdate;
						video.addEventListener('ended', onVideoEnded);
						$scope.scrubberOptions = generateScrupperOoptions();
						$scope.volumeScrubberOptions = generateVolumeScrubberOptions();
					});
				}

        //$scope.controlsVisible = true;
        function showControls() {
          $elem.removeClass('nocursor');
          $timeout.cancel(controlDisplayTimeout);
          $timeout.cancel(overlayTimeout);
          $scope.controlsVisible = true;
          $scope.overlayVisible = false;


          controlDisplayTimeout = $timeout(function(){
            $scope.controlsVisible = false;

            if(!$scope.playing){
              overlayTimeout = $timeout(function () {
                if(!$scope.playing){
                  $scope.overlayVisible = true;
                }
              }, 5000);
            }else{
              $elem.addClass('nocursor');
            }

          }, 1000);
        }

				function generateScrupperOoptions() {
					return {
						orientation: 'horizontal',
						min: 0,
						max: 255,
						range: 'min',
						change: function (e, slider) {
							angular.element('#playerDurationSlider .ui-slider-handle').blur();
						},
						stop: function (e, slider) {
							angular.element('#playerDurationSlider .ui-slider-handle').blur();
							video.currentTime = slider.value;
							$scope.currentTime = slider.value;
							$scope.options.onTimeChange(slider, $scope.videoDuration);

						}
					};
				}

				function generateVolumeScrubberOptions() {
					return {
						orientation: 'vertical',
						range: 'min',
						change: function (e, slider) {
							setVolume(slider);
							angular.element('#playerVolumeSlider .ui-slider-handle').blur();
						},
						slide: function (e, slider) {
							setVolume(slider);
							angular.element('#playerVolumeSlider .ui-slider-handle').blur();
						}
					};
				}

				function closeVideo() {

					//If full screen is enabled, it will be canceled.
					if ($scope.isFullScreen = true) {<commit_msg>fixed fullscreen on video exit<commit_after>'use strict';

angular.module('streama').directive('streamaVideoPlayer', [
  'uploadService', 'localStorageService', '$timeout', 'playerService', '$http',
  function (uploadService, localStorageService, $timeout, playerService, $http) {

    return {
      restrict: 'AE',
      templateUrl: '/streama/streama-video-player.htm',
      scope: {
        options: '='
      },

      link: function ($scope, $elem, $attrs) {
				var video;
        var controlDisplayTimeout;
        var overlayTimeout;
        var volumeChangeTimeout;
        var currentTimeChangeTimeout;
				var currEpisode = null;
        var skippingDuration = 20;  //Skipping duration for holding an arrow key to left or right.
        var longSkippingDuration = 60; //Skipping duration for holding ctrl + arrow key.
        var skipIntro = true;         //Userflag intro should be skipped
        var minimizeOnOutro = true;   //Userflag skip to next episode on outro
				var videoSrc = $scope.options.videoSrc.toString();

				$scope.showControls = showControls;
				$scope.toggleSelectEpisodes = toggleSelectEpisodes;
				$scope.createNewPlayerSession = createNewPlayerSession;
        $scope.toggleTextTrack = toggleTextTrack;
        $scope.playerVolumeToggle = playerVolumeToggle;
				$scope.play = play;
				$scope.pause = pause;
				$scope.closeVideo = closeVideo;
				$scope.clickVideo = clickVideo;
				$scope.fullScreen = toggleFullScreen;
				$scope.next = $scope.options.onNext;
				$scope.isInitialized = false;
				$scope.loading = true;
				$scope.initialPlay = false;

				$http.head(videoSrc)
          .success(function(){
            initDirective();
          })
          .error(function(data, status) {
            if(status == 406){
              $scope.options.onError('FILE_IN_FS_NOT_FOUND');
            }
          });

				function initDirective() {
					$scope.isInitialized = true;

					$elem.addClass('nocursor');

					initMouseWheel();
					initMousetrap();
					initExternalTriggers();
					initIsMobile();
					$scope.volumeLevel = localStorageService.get('volumeLevel') || 5;
					$scope.$on('$destroy', onDirectiveDestroy);
					$scope.$on('$stateChangeSuccess', onStateChangeSuccess);

					$timeout(function () {
						var $video = $elem.find('video');
						$video.bind("contextmenu",function(){return false;});
						video = $video[0];
						video.oncanplay = oncanplay;
						video.onwaiting = onwaiting;
						video.onplaying = onplaying;
						video.onerror = onerror;
						video.ontimeupdate = ontimeupdate;
						video.addEventListener('ended', onVideoEnded);
						$scope.scrubberOptions = generateScrupperOoptions();
						$scope.volumeScrubberOptions = generateVolumeScrubberOptions();
					});
				}

        //$scope.controlsVisible = true;
        function showControls() {
          $elem.removeClass('nocursor');
          $timeout.cancel(controlDisplayTimeout);
          $timeout.cancel(overlayTimeout);
          $scope.controlsVisible = true;
          $scope.overlayVisible = false;


          controlDisplayTimeout = $timeout(function(){
            $scope.controlsVisible = false;

            if(!$scope.playing){
              overlayTimeout = $timeout(function () {
                if(!$scope.playing){
                  $scope.overlayVisible = true;
                }
              }, 5000);
            }else{
              $elem.addClass('nocursor');
            }

          }, 1000);
        }

				function generateScrupperOoptions() {
					return {
						orientation: 'horizontal',
						min: 0,
						max: 255,
						range: 'min',
						change: function (e, slider) {
							angular.element('#playerDurationSlider .ui-slider-handle').blur();
						},
						stop: function (e, slider) {
							angular.element('#playerDurationSlider .ui-slider-handle').blur();
							video.currentTime = slider.value;
							$scope.currentTime = slider.value;
							$scope.options.onTimeChange(slider, $scope.videoDuration);

						}
					};
				}

				function generateVolumeScrubberOptions() {
					return {
						orientation: 'vertical',
						range: 'min',
						change: function (e, slider) {
							setVolume(slider);
							angular.element('#playerVolumeSlider .ui-slider-handle').blur();
						},
						slide: function (e, slider) {
							setVolume(slider);
							angular.element('#playerVolumeSlider .ui-slider-handle').blur();
						}
					};
				}

				function closeVideo() {

					//If full screen is enabled, it will be canceled.
					if ($scope.isFullScreen == true) {
{'fraction_non_alphanumeric': 0.1245054945054945, 'fraction_numerical': 0.004615384615384616, 'mean_word_length': 2.4803059273422563, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7395310', 'n_tokens_mistral': 3232, 'n_tokens_neox': 2507, 'n_words': 502}