<commit_before>var gui = require('nw.gui');

var isMaximized = false;

var Player = function() {
	t = this,
	t.win = gui.Window.get(),

	t.videoId = 0,

	t.config = {
		video: {
			def: '720',
			lang: 'EN'
		},
		subtitles: {
			show: true,
			size: 30,
			color: '#FFFFFF',
			lang: 'ES'
		}
	},

	t.init = function() {

		// Load config
		t.loadConfig();

		// Check if window exists
		t.checkVideoId();

		// Load data from cache
    	if (videoData != null) {
    		var href = videoData.url, subtitles = videoData.subtitles, source = videoData.source;
    	} else {
    		alert('El video no se ha podido cargar correctamente.');
    		t.closeVideo();
    		t.win.close(true);
    		return;
    	}

		// Set title
		if (mainWindow.window.isWin) {
			var toolbar = $('#toolbar');

			toolbar.find('span').html(videoData.title);

			toolbar.find('.min').click(function() {
				t.win.minimize();
			})
			toolbar.find('.max').click(function() {
				isMaximized ? t.win.unmaximize() : t.win.maximize();
			})
			toolbar.find('.close').click(function() {
				t.win.close();
			})
			$('body').addClass('isWindows');

			// Resize player with toolbar
			$('#video-player').height($(window).height()-toolbar.outerHeight());
			$(window).resize(function() {
				$('#video-player').height($(window).height()-toolbar.outerHeight());
			})
		} else if (mainWindow.window.isMac) {
			$('body').addClass('isMac');
		}

    	t.win.on('close', function() {
			if (confirm('¿Seguro que deseas salir? El video actual se cerrará.')) {
				t.closeVideo();
				this.close(true);
			} else {
				this.focus();
			}
    	})

		var player_container = $('#video-player').show();

    	player_container.empty();

		var tracks = '';
		for (var i in subtitles) {
			if (subtitles[i].def == source.def) {
				tracks += '<track kind="subtitles" src="' + subtitles[i].url + '" srclang="'+subtitles[i].lang.toLowerCase()+'" label="'+(mainWindow.window.languages[subtitles[i].lang]!='undefined'?mainWindow.window.languages[subtitles[i].lang]:subtitles[i].lang)+'" charset="ISO-8859-1" '+((subtitles[i].lang == t.config.subtitles.lang)?'default':'')+' />';
			}
		}

    	$('<video id="player" width="100%" height="100%" preload autoplay><source src="'+href+'" type="video/mp4" />'+tracks+'</video>').appendTo(player_container);

    	if (!document.createElement('video').canPlayType('video/mp4')) {
	    	return alert('La aplicación no soporta reproducir mp4');
	    }

	    var video = $('video');

	    video.mediaelementplayer({
			videoVolume: 'horizontal',
			features: ['playpause','current','progress','duration','fullscreen','volume','tracks','torrentinfo','fontawesome', 'customtracks'],
			success : function(mediaElement, domObject, player) {
        t.mePlayer = player;
				// $(mediaElement).on('ended', function(){
				// }).on('loadeddata',function() {
				// });
			}
		});

	    // Loading info event
		t.loadVideoStats();

    	// Player events
<commit_msg>Hide Cursor when playing<commit_after>var gui = require('nw.gui');

var isMaximized = false;

var Player = function() {
	t = this,
	t.win = gui.Window.get(),

	t.videoId = 0,

	t.config = {
		video: {
			def: '720',
			lang: 'EN'
		},
		subtitles: {
			show: true,
			size: 30,
			color: '#FFFFFF',
			lang: 'ES'
		}
	},

	t.init = function() {

		// Load config
		t.loadConfig();

		// Check if window exists
		t.checkVideoId();

		// Load data from cache
    	if (videoData != null) {
    		var href = videoData.url, subtitles = videoData.subtitles, source = videoData.source;
    	} else {
    		alert('El video no se ha podido cargar correctamente.');
    		t.closeVideo();
    		t.win.close(true);
    		return;
    	}

		// Set title
		if (mainWindow.window.isWin) {
			var toolbar = $('#toolbar');

			toolbar.find('span').html(videoData.title);

			toolbar.find('.min').click(function() {
				t.win.minimize();
			})
			toolbar.find('.max').click(function() {
				isMaximized ? t.win.unmaximize() : t.win.maximize();
			})
			toolbar.find('.close').click(function() {
				t.win.close();
			})
			$('body').addClass('isWindows');

			// Resize player with toolbar
			$('#video-player').height($(window).height()-toolbar.outerHeight());
			$(window).resize(function() {
				$('#video-player').height($(window).height()-toolbar.outerHeight());
			})
		} else if (mainWindow.window.isMac) {
			$('body').addClass('isMac');
		}

    	t.win.on('close', function() {
			if (confirm('¿Seguro que deseas salir? El video actual se cerrará.')) {
				t.closeVideo();
				this.close(true);
			} else {
				this.focus();
			}
    	})

		var player_container = $('#video-player').show();

    	player_container.empty();

		var tracks = '';
		for (var i in subtitles) {
			if (subtitles[i].def == source.def) {
				tracks += '<track kind="subtitles" src="' + subtitles[i].url + '" srclang="'+subtitles[i].lang.toLowerCase()+'" label="'+(mainWindow.window.languages[subtitles[i].lang]!='undefined'?mainWindow.window.languages[subtitles[i].lang]:subtitles[i].lang)+'" charset="ISO-8859-1" '+((subtitles[i].lang == t.config.subtitles.lang)?'default':'')+' />';
			}
		}

    	$('<video id="player" width="100%" height="100%" preload autoplay><source src="'+href+'" type="video/mp4" />'+tracks+'</video>').appendTo(player_container);

    	if (!document.createElement('video').canPlayType('video/mp4')) {
	    	return alert('La aplicación no soporta reproducir mp4');
	    }

	    var video = $('video');

	    video.mediaelementplayer({
			videoVolume: 'horizontal',
			features: ['playpause','current','progress','duration','fullscreen','volume','tracks','torrentinfo','fontawesome', 'customtracks'],
			success : function(mediaElement, domObject, player) {
        		t.mePlayer = player;
        		// TODO: Move me into a mediaelement plugin?
				player.container.bind('controlsshown', function() {
					player.container.css('cursor', 'auto')
				})
				player.container.bind('controlshidden', function() {
					player.container.css('cursor', 'none')
				})
			}
		});

	    // Loading info event
		t.loadVideoStats();

    	// Player events

{'fraction_non_alphanumeric': 0.20098684210526316, 'fraction_numerical': 0.006578947368421052, 'mean_word_length': 3.3685344827586206, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '59802', 'n_tokens_mistral': 2398, 'n_tokens_neox': 2058, 'n_words': 367}