v2.0.17~dfsg/ 0000755 0000000 0000000 00000000000 12625374554 011546 5 ustar root root v2.0.17~dfsg/src/ 0000755 0000000 0000000 00000000000 12625374554 012335 5 ustar root root v2.0.17~dfsg/src/jaris/ 0000755 0000000 0000000 00000000000 12625374554 013445 5 ustar root root v2.0.17~dfsg/src/jaris/utils/ 0000755 0000000 0000000 00000000000 12625374554 014605 5 ustar root root v2.0.17~dfsg/src/jaris/utils/Utils.hx 0000644 0000000 0000000 00000010273 12625374554 016251 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.utils;
/**
* Some utility functions
*/
class Utils
{
/**
* Converts degrees to radians for easy rotation where applicable
* @param value A radian value to convert
* @return conversion of degree to radian
*/
public static function degreesToRadians(value:Float):Float
{
return (Math.PI / 180) * value;
}
/**
* Converts a float value representing seconds to a readale string
* @param time A given time in seconds
* @return A string in the format 00:00:00
*/
public static function formatTime(time:Float):String
{
var seconds:String = "";
var minutes:String = "";
var hours:String = "";
var timeString:String = "";
if (((time / 60) / 60) >= 1)
{
if (Math.floor((time / 60)) / 60 < 10)
{
hours = "0" + Math.floor((time / 60) / 60) + ":";
}
else
{
hours = Math.floor((time / 60) / 60) + ":";
}
if (Math.floor((time / 60) % 60) < 10)
{
minutes = "0" + Math.floor((time / 60) % 60) + ":";
}
else
{
minutes = Math.floor((time / 60) % 60) + ":";
}
if (Math.floor(time % 60) < 10)
{
seconds = "0" + Math.floor(time % 60);
}
else
{
seconds = Std.string(Math.floor(time % 60));
}
}
else if((time / 60) >= 1)
{
hours = "00:";
if (Math.floor(time / 60) < 10)
{
minutes = "0" + Math.floor(time / 60) + ":";
}
else
{
minutes = Math.floor(time / 60) + ":";
}
if (Math.floor(time % 60) < 10)
{
seconds = "0" + Math.floor(time % 60);
}
else
{
seconds = Std.string(Math.floor(time % 60));
}
}
else
{
hours = "00:";
minutes = "00:";
if (Math.floor(time) < 10)
{
seconds = "0" + Math.floor(time);
}
else
{
seconds = Std.string(Math.floor(time));
}
}
timeString += hours + minutes + seconds;
return timeString;
}
/**
* Converts a given rtmp source to a valid format for NetStream
* @param source
* @return
*/
public static function rtmpSourceParser(source:String):String
{
if (source.indexOf(".flv") != -1)
{
return source.split(".flv").join("");
}
else if (source.indexOf(".mp3") != -1)
{
return "mp3:" + source.split(".mp3").join("");
}
else if (source.indexOf(".mp4") != -1)
{
return "mp4:" + source;
}
else if (source.indexOf(".f4v") != -1)
{
return "mp4:" + source;
}
return source;
}
/**
* Changes a youtube url to the format youtube.com/v/video_id
* @param source
* @return
*/
public static function youtubeSourceParse(source:String):String
{
return source.split("watch?v=").join("v/");
}
}
v2.0.17~dfsg/src/jaris/display/ 0000755 0000000 0000000 00000000000 12625374554 015112 5 ustar root root v2.0.17~dfsg/src/jaris/display/Poster.hx 0000644 0000000 0000000 00000011266 12625374554 016735 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.display;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.Lib;
import flash.net.URLRequest;
import jaris.events.PlayerEvents;
import jaris.player.InputType;
import jaris.player.Player;
/**
* To display an png, jpg or gif as preview of video content
*/
class Poster extends Sprite
{
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _loader:Loader;
private var _source:String;
private var _width:Float;
private var _height:Float;
private var _loading:Bool;
private var _loaderStatus:jaris.display.Loader;
private var _player:Player;
public function new(source:String)
{
super();
_stage = Lib.current.stage;
_movieClip = Lib.current;
_loader = new Loader();
_source = source;
_loading = true;
//Reads flash vars
var parameters:Dynamic = flash.Lib.current.loaderInfo.parameters;
//Draw Loader status
var loaderColors:Array = ["", "", "", ""];
loaderColors[0] = parameters.brightcolor != null ? parameters.brightcolor : "";
loaderColors[1] = parameters.controlcolor != null ? parameters.controlcolor : "";
_loaderStatus = new jaris.display.Loader();
_loaderStatus.show();
_loaderStatus.setColors(loaderColors);
addChild(_loaderStatus);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onNotLoaded);
_loader.load(new URLRequest(source));
}
/**
* Triggers when the poster image could not be loaded
* @param event
*/
private function onNotLoaded(event:IOErrorEvent):Void
{
_loaderStatus.hide();
removeChild(_loaderStatus);
}
/**
* Triggers when the poster image finalized loading
* @param event
*/
private function onLoaderComplete(event:Event):Void
{
_loaderStatus.hide();
removeChild(_loaderStatus);
addChild(_loader);
_width = this.width;
_height = this.height;
_loading = false;
_stage.addEventListener(Event.RESIZE, onStageResize);
resizeImage();
}
/**
* Triggers when the stage is resized to resize the poster image
* @param event
*/
private function onStageResize(event:Event):Void
{
resizeImage();
}
private function onPlayerMediaInitialized(event:PlayerEvents)
{
if (_player.getType() == InputType.VIDEO)
{
this.visible = false;
}
}
private function onPlayerPlay(event:PlayerEvents)
{
if (_player.getType() == InputType.VIDEO)
{
this.visible = false;
}
}
private function onPlayBackFinished(event:PlayerEvents)
{
this.visible = true;
}
/**
* Resizes the poster image to take all the stage
*/
private function resizeImage():Void
{
this.height = _stage.stageHeight;
this.width = ((_width / _height) * this.height);
this.x = (_stage.stageWidth / 2) - (this.width / 2);
}
/**
* To check if the poster image stills loading
* @return true if stills loading false if loaded
*/
public function isLoading():Bool
{
return _loading;
}
public function setPlayer(player:Player):Void
{
_player = player;
_player.addEventListener(PlayerEvents.MEDIA_INITIALIZED, onPlayerMediaInitialized);
_player.addEventListener(PlayerEvents.PLAYBACK_FINISHED, onPlayBackFinished);
_player.addEventListener(PlayerEvents.PLAY_PAUSE, onPlayerPlay);
}
}
v2.0.17~dfsg/src/jaris/display/Logo.hx 0000644 0000000 0000000 00000011420 12625374554 016351 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.display;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.Lib;
import flash.net.URLRequest;
/**
* To display an image in jpg, png or gif format as logo
*/
class Logo extends Sprite
{
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _loader:Loader;
private var _position:String;
private var _alpha:Float;
private var _source:String;
private var _width:Float;
private var _link:String;
private var _loading:Bool;
public function new(source:String, position:String, alpha:Float, width:Float=0.0)
{
super();
_stage = Lib.current.stage;
_movieClip = Lib.current;
_loader = new Loader();
_position = position;
_alpha = alpha;
_source = source;
_width = width;
_loading = true;
this.tabEnabled = false;
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onNotLoaded);
_loader.load(new URLRequest(source));
}
/**
* Triggers when the logo image could not be loaded
* @param event
*/
private function onNotLoaded(event:IOErrorEvent):Void
{
//Image not loaded
}
/**
* Triggers when the logo image finished loading.
* @param event
*/
private function onLoaderComplete(event:Event):Void
{
addChild(_loader);
setWidth(_width);
setPosition(_position);
setAlpha(_alpha);
_loading = false;
_stage.addEventListener(Event.RESIZE, onStageResize);
}
/**
* Recalculate logo position on stage resize
* @param event
*/
private function onStageResize(event:Event):Void
{
setPosition(_position);
}
/**
* Opens the an url when the logo is clicked
* @param event
*/
private function onLogoClick(event:MouseEvent):Void
{
Lib.getURL(new URLRequest(_link), "_blank");
}
/**
* Position where logo will be showing
* @param position values could be top left, top right, bottom left, bottom right
*/
public function setPosition(position:String):Void
{
switch(position)
{
case "top left":
this.x = 25;
this.y = 25;
case "top right":
this.x = _stage.stageWidth - this._width - 25;
this.y = 25;
case "bottom left":
this.x = 25;
this.y = _stage.stageHeight - this.height - 25;
case "bottom right":
this.x = _stage.stageWidth - this.width - 25;
this.y = _stage.stageHeight - this.height - 25;
default:
this.x = 25;
this.y = 25;
}
}
/**
* To set logo transparency
* @param alpha
*/
public function setAlpha(alpha:Float):Void
{
this.alpha = alpha;
}
/**
* Sets logo width and recalculates height keeping aspect ratio
* @param width
*/
public function setWidth(width:Float):Void
{
if (width > 0)
{
this.height = (this.height / this.width) * width;
this.width = width;
}
}
/**
* Link that opens when clicked the logo image is clicked
* @param link
*/
public function setLink(link:String):Void
{
_link = link;
this.buttonMode = true;
this.useHandCursor = true;
this.addEventListener(MouseEvent.CLICK, onLogoClick);
}
/**
* To check if the logo stills loading
* @return true if loading false otherwise
*/
public function isLoading():Bool
{
return _loading;
}
}
v2.0.17~dfsg/src/jaris/display/Menu.hx 0000644 0000000 0000000 00000016555 12625374554 016373 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.display;
import flash.display.MovieClip;
import flash.events.ContextMenuEvent;
import flash.Lib;
import flash.net.URLRequest;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import jaris.player.Player;
import jaris.player.AspectRatio;
import jaris.Version;
/**
* Modify original context menu
*/
class Menu
{
private var _movieClip:MovieClip;
public static var _player:Player;
private var _contextMenu:ContextMenu;
private var _jarisVersionMenuItem:ContextMenuItem;
private var _playMenuItem:ContextMenuItem;
private var _fullscreenMenuItem:ContextMenuItem;
private var _aspectRatioMenuItem:ContextMenuItem;
private var _muteMenuItem:ContextMenuItem;
private var _volumeUpMenuItem:ContextMenuItem;
private var _volumeDownMenuItem:ContextMenuItem;
private var _qualityContextMenu:ContextMenuItem;
public function new(player:Player)
{
_movieClip = Lib.current;
_player = player;
//Initialize context menu replacement
_contextMenu = new ContextMenu();
_contextMenu.hideBuiltInItems();
_contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, onMenuOpen);
//Initialize each menu item
_jarisVersionMenuItem = new ContextMenuItem("Jaris Player v" + Version.NUMBER + " " + Version.STATUS, true, true, true);
_jarisVersionMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onJarisVersion);
_playMenuItem = new ContextMenuItem("Play (SPACE)", true, true, true);
_playMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onPlay);
_fullscreenMenuItem = new ContextMenuItem("Fullscreen View (F)");
_fullscreenMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onFullscreen);
_aspectRatioMenuItem = new ContextMenuItem("Aspect Ratio (original) (TAB)");
_aspectRatioMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onAspectRatio);
_muteMenuItem = new ContextMenuItem("Mute (M)");
_muteMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onMute);
_volumeUpMenuItem = new ContextMenuItem("Volume + (arrow UP)");
_volumeUpMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onVolumeUp);
_volumeDownMenuItem = new ContextMenuItem("Volume - (arrow DOWN)");
_volumeDownMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onVolumeDown);
_qualityContextMenu = new ContextMenuItem("Lower Quality", true, true, true);
_qualityContextMenu.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQuality);
//add all context menu items to context menu object
_contextMenu.customItems.push(_jarisVersionMenuItem);
_contextMenu.customItems.push(_playMenuItem);
_contextMenu.customItems.push(_fullscreenMenuItem);
_contextMenu.customItems.push(_aspectRatioMenuItem);
_contextMenu.customItems.push(_muteMenuItem);
_contextMenu.customItems.push(_volumeUpMenuItem);
_contextMenu.customItems.push(_volumeDownMenuItem);
_contextMenu.customItems.push(_qualityContextMenu);
//override default context menu
_movieClip.contextMenu = _contextMenu;
}
/**
* Update context menu item captions depending on player status before showing them
* @param event
*/
private function onMenuOpen(event:ContextMenuEvent):Void
{
if (_player.isPlaying())
{
_playMenuItem.caption = "Pause (SPACE)";
}
else
{
_playMenuItem.caption = "Play (SPACE)";
}
if (_player.isFullscreen())
{
_fullscreenMenuItem.caption = "Normal View";
}
else
{
_fullscreenMenuItem.caption = "Fullscreen View (F)";
}
if (_player.getMute())
{
_muteMenuItem.caption = _player.isFullscreen()?"Unmute":"Unmute (M)";
}
else
{
_muteMenuItem.caption = _player.isFullscreen()?"Mute":"Mute (M)";
}
switch(_player.getAspectRatioString())
{
case "original":
_aspectRatioMenuItem.caption = "Aspect Ratio (1:1) (TAB)";
case "1:1":
_aspectRatioMenuItem.caption = "Aspect Ratio (3:2) (TAB)";
case "3:2":
_aspectRatioMenuItem.caption = "Aspect Ratio (4:3) (TAB)";
case "4:3":
_aspectRatioMenuItem.caption = "Aspect Ratio (5:4) (TAB)";
case "5:4":
_aspectRatioMenuItem.caption = "Aspect Ratio (14:9) (TAB)";
case "14:9":
_aspectRatioMenuItem.caption = "Aspect Ratio (14:10) (TAB)";
case "14:10":
_aspectRatioMenuItem.caption = "Aspect Ratio (16:9) (TAB)";
case "16:9":
_aspectRatioMenuItem.caption = "Aspect Ratio (16:10) (TAB)";
case "16:10":
_aspectRatioMenuItem.caption = "Aspect Ratio (original) (TAB)";
}
if (_player.getQuality())
{
_qualityContextMenu.caption = "Lower Quality";
}
else
{
_qualityContextMenu.caption = "Higher Quality";
}
}
/**
* Open jaris player website
* @param event
*/
private function onJarisVersion(event:ContextMenuEvent)
{
Lib.getURL(new URLRequest("http://jaris.sourceforge.net"), "_blank");
}
/**
* Toggles playback
* @param event
*/
private function onPlay(event:ContextMenuEvent)
{
_player.togglePlay();
}
/**
* Toggles fullscreen
* @param event
*/
private function onFullscreen(event:ContextMenuEvent)
{
_player.toggleFullscreen();
}
/**
* Toggles aspect ratio
* @param event
*/
private function onAspectRatio(event:ContextMenuEvent)
{
_player.toggleAspectRatio();
}
/**
* Toggles mute
* @param event
*/
private function onMute(event:ContextMenuEvent)
{
_player.toggleMute();
}
/**
* Raise volume
* @param event
*/
private function onVolumeUp(event:ContextMenuEvent)
{
_player.volumeUp();
}
/**
* Lower volume
* @param event
*/
private function onVolumeDown(event:ContextMenuEvent)
{
_player.volumeDown();
}
/**
* Toggle video quality
* @param event
*/
private function onQuality(event:ContextMenuEvent)
{
_player.toggleQuality();
}
}
v2.0.17~dfsg/src/jaris/display/Loader.hx 0000644 0000000 0000000 00000011635 12625374554 016667 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.display;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.Lib;
/**
* Draws a loading bar
*/
class Loader extends Sprite
{
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _background:Sprite;
private var _loaderTrack:Sprite;
private var _loaderThumb:Sprite;
private var _visible:Bool;
private var _brightColor:UInt;
private var _controlColor:UInt;
private var _forward:Bool;
public function new()
{
super();
_stage = Lib.current.stage;
_movieClip = Lib.current;
_background = new Sprite();
addChild(_background);
_loaderTrack = new Sprite();
addChild(_loaderTrack);
_loaderThumb = new Sprite();
addChild(_loaderThumb);
_brightColor = 0x4c4c4c;
_controlColor = 0xFFFFFF;
_forward = true;
_visible = true;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
_stage.addEventListener(Event.RESIZE, onResize);
drawLoader();
}
/**
* Animation of a thumb moving on the track
* @param event
*/
private function onEnterFrame(event:Event):Void
{
if (_visible)
{
if (_forward)
{
if ((_loaderThumb.x + _loaderThumb.width) >= (_loaderTrack.x + _loaderTrack.width))
{
_forward = false;
}
else
{
_loaderThumb.x += 10;
}
}
else
{
if (_loaderThumb.x <= _loaderTrack.x)
{
_forward = true;
}
else
{
_loaderThumb.x -= 10;
}
}
}
}
/**
* Redraws the loader to match new stage size
* @param event
*/
private function onResize(event:Event):Void
{
drawLoader();
}
/**
* Draw loader graphics
*/
private function drawLoader():Void
{
//Clear graphics
_background.graphics.clear();
_loaderTrack.graphics.clear();
_loaderThumb.graphics.clear();
//Draw background
var backgroundWidth:Float = (65 / 100) * _stage.stageWidth;
var backgroundHeight:Float = 30;
_background.x = (_stage.stageWidth / 2) - (backgroundWidth / 2);
_background.y = (_stage.stageHeight / 2) - (backgroundHeight / 2);
_background.graphics.lineStyle();
_background.graphics.beginFill(_brightColor, 0.5);
_background.graphics.drawRoundRect(0, 0, backgroundWidth, backgroundHeight, 6, 6);
_background.graphics.endFill();
//Draw track
var trackWidth:Float = (50 / 100) * _stage.stageWidth;
var trackHeight:Float = 15;
_loaderTrack.x = (_stage.stageWidth / 2) - (trackWidth / 2);
_loaderTrack.y = (_stage.stageHeight / 2) - (trackHeight / 2);
_loaderTrack.graphics.lineStyle(2, _controlColor);
_loaderTrack.graphics.drawRect(0, 0, trackWidth, trackHeight);
//Draw thumb
_loaderThumb.x = _loaderTrack.x;
_loaderThumb.y = _loaderTrack.y;
_loaderThumb.graphics.lineStyle();
_loaderThumb.graphics.beginFill(_controlColor, 1);
_loaderThumb.graphics.drawRect(0, 0, trackHeight, trackHeight);
}
/**
* Stops drawing the loader
*/
public function hide():Void
{
this.visible = false;
_visible = false;
}
/**
* Starts drawing the loader
*/
public function show():Void
{
this.visible = true;
_visible = true;
}
/**
* Set loader colors
* @param colors
*/
public function setColors(colors:Array):Void
{
_brightColor = colors[0].length > 0? Std.parseInt("0x" + colors[0]) : 0x4c4c4c;
_controlColor = colors[1].length > 0? Std.parseInt("0x" + colors[1]) : 0xFFFFFF;
drawLoader();
}
}
v2.0.17~dfsg/src/jaris/animation/ 0000755 0000000 0000000 00000000000 12625374554 015424 5 ustar root root v2.0.17~dfsg/src/jaris/animation/Animation.hx 0000644 0000000 0000000 00000004741 12625374554 017712 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.animation;
/**
* Gives quick access usage to jaris animations
*/
class Animation
{
/**
* Quick access to fade in effect
* @param object the object to animate
* @param seconds the duration of the animation
*/
public static function fadeIn(object:Dynamic, seconds:Float):Void
{
var animation:AnimationsBase = new AnimationsBase();
animation.fadeIn(object, seconds);
}
/**
* Quick access to fade out effect
* @param object the object to animate
* @param seconds the duration of the animation
*/
public static function fadeOut(object:Dynamic, seconds:Float):Void
{
var animation:AnimationsBase = new AnimationsBase();
animation.fadeOut(object, seconds);
}
/**
* Quick access to slide in effect
* @param object the object to animate
* @param position could be top, left, bottom or right
* @param seconds the duration of the animation
*/
public static function slideIn(object:Dynamic, position:String, seconds:Float):Void
{
var animation:AnimationsBase = new AnimationsBase();
animation.slideIn(object, position, seconds);
}
/**
* Quick access to slide out effect
* @param object the object to animate
* @param position could be top, left, bottom or right
* @param seconds the duration of the animation
*/
public static function slideOut(object:Dynamic, position:String, seconds:Float):Void
{
var animation:AnimationsBase = new AnimationsBase();
animation.slideOut(object, position, seconds);
}
}
v2.0.17~dfsg/src/jaris/animation/AnimationsBase.hx 0000644 0000000 0000000 00000020725 12625374554 020670 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.animation;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.TimerEvent;
import flash.Lib;
import flash.utils.Timer;
/**
* Jaris main animations
*/
class AnimationsBase
{
private var _fadeInTimer:Timer;
private var _fadeOutTimer:Timer;
private var _slideInTimer:Timer;
private var _slideInOrigX:Float;
private var _slideInOrigY:Float;
private var _slideInPosition:String;
private var _slideInIncrements:Float;
private var _slideOutTimer:Timer;
private var _slideOutOrigX:Float;
private var _slideOutOrigY:Float;
private var _slideOutPosition:String;
private var _slideOutIncrements:Float;
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _currentObject:Dynamic;
public function new()
{
_stage = Lib.current.stage;
_movieClip = Lib.current;
}
/**
* Moves an object until is shown
* @param event
*/
private function slideInTimer(event:TimerEvent):Void
{
var last:Bool = false;
switch(_slideInPosition)
{
case "top":
if (_currentObject.y >= _slideInOrigY) { last = true; }
_currentObject.y += _slideInIncrements;
case "left":
if (_currentObject.x >= _slideInOrigX) { last = true; }
_currentObject.x += _slideInIncrements;
case "bottom":
if (_currentObject.y <= _slideInOrigY) { last = true; }
_currentObject.y -= _slideInIncrements;
case "right":
if (_currentObject.x <= _slideInOrigX) { last = true; }
_currentObject.x -= _slideInIncrements;
}
if (last)
{
_currentObject.x = _slideInOrigX;
_currentObject.y = _slideInOrigY;
_slideInTimer.stop();
}
}
/**
* Moves an object until is hidden
* @param event
*/
private function slideOutTimer(event:TimerEvent):Void
{
if (((_currentObject.x + _currentObject.width) < 0) || (_currentObject.y + _currentObject.height < 0))
{
_currentObject.visible = false;
_currentObject.x = _slideOutOrigX;
_currentObject.y = _slideOutOrigY;
_slideOutTimer.stop();
}
else if (((_currentObject.x) > _stage.stageWidth) || (_currentObject.y > _stage.stageHeight))
{
_currentObject.visible = false;
_currentObject.x = _slideOutOrigX;
_currentObject.y = _slideOutOrigY;
_slideOutTimer.stop();
}
else
{
switch(_slideOutPosition)
{
case "top":
_currentObject.y -= _slideOutIncrements;
case "left":
_currentObject.x -= _slideOutIncrements;
case "bottom":
_currentObject.y += _slideOutIncrements;
case "right":
_currentObject.x += _slideOutIncrements;
}
}
}
/**
* Lower object transparency until not visible
* @param event
*/
private function fadeOutTimer(event:TimerEvent):Void
{
if (_currentObject.alpha > 0)
{
_currentObject.alpha -= 1 / 10;
}
else
{
_currentObject.visible = false;
_fadeOutTimer.stop();
}
}
/**
* Highers object transparency until visible
* @param event
*/
private function fadeInTimer(event:TimerEvent):Void
{
if (_currentObject.alpha < 1)
{
_currentObject.alpha += 1 / 10;
}
else
{
_fadeInTimer.stop();
}
}
/**
* Effect that moves an object into stage
* @param object the element to move
* @param slidePosition could be top, left bottom or right
* @param speed the time in seconds for duration of the animation
*/
public function slideIn(object:Dynamic, slidePosition:String, speed:Float=1000):Void
{
if (object.visible)
{
object.visible = false;
}
_slideInOrigX = object.x;
_slideInOrigY = object.y;
_slideInPosition = slidePosition;
var increments:Float = 0;
switch(slidePosition)
{
case "top":
object.y = 0 - object.height;
increments = object.height + _slideInOrigY;
case "left":
object.x = 0 - object.width;
increments = object.width + _slideInOrigX;
case "bottom":
object.y = _stage.stageHeight;
increments = _stage.stageHeight - _slideInOrigY;
case "right":
object.x = _stage.stageWidth;
increments = _stage.stageWidth - _slideInOrigX;
}
_slideInIncrements = increments / (speed / 100);
_currentObject = object;
_currentObject.visible = true;
_currentObject.alpha = 1;
_slideInTimer = new Timer(speed / 100);
_slideInTimer.addEventListener(TimerEvent.TIMER, slideInTimer);
_slideInTimer.start();
}
/**
* Effect that moves an object out of stage
* @param object the element to move
* @param slidePosition could be top, left bottom or right
* @param speed the time in seconds for duration of the animation
*/
public function slideOut(object:Dynamic, slidePosition:String, speed:Float=1000):Void
{
if (!object.visible)
{
object.visible = true;
}
_slideOutOrigX = object.x;
_slideOutOrigY = object.y;
_slideOutPosition = slidePosition;
var increments:Float = 0;
switch(slidePosition)
{
case "top":
increments = object.height + _slideOutOrigY;
case "left":
increments = object.width + _slideOutOrigX;
case "bottom":
increments = _stage.stageHeight - _slideOutOrigY;
case "right":
increments = _stage.stageWidth - _slideOutOrigX;
}
_slideOutIncrements = increments / (speed / 100);
_currentObject = object;
_currentObject.visible = true;
_currentObject.alpha = 1;
_slideOutTimer = new Timer(speed / 100);
_slideOutTimer.addEventListener(TimerEvent.TIMER, slideOutTimer);
_slideOutTimer.start();
}
/**
* Effect that dissapears an object from stage
* @param object the element to dissapear
* @param speed the time in seconds for the duration of the animation
*/
public function fadeOut(object:Dynamic, speed:Float=500):Void
{
if (!object.visible)
{
object.visible = true;
}
object.alpha = 1;
_currentObject = object;
_fadeOutTimer = new Timer(speed / 10);
_fadeOutTimer.addEventListener(TimerEvent.TIMER, fadeOutTimer);
_fadeOutTimer.start();
}
/**
* Effect that shows a hidden object an in stage
* @param object the element to show
* @param speed the time in seconds for the duration of the animation
*/
public function fadeIn(object:Dynamic, speed:Float=500):Void
{
if (object.visible)
{
object.visible = false;
}
object.alpha = 0;
_currentObject = object;
_currentObject.visible = true;
_fadeInTimer = new Timer(speed / 10);
_fadeInTimer.addEventListener(TimerEvent.TIMER, fadeInTimer);
_fadeInTimer.start();
}
}
v2.0.17~dfsg/src/jaris/events/ 0000755 0000000 0000000 00000000000 12625374554 014751 5 ustar root root v2.0.17~dfsg/src/jaris/events/PlayerEvents.hx 0000644 0000000 0000000 00000005510 12625374554 017734 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.events;
import flash.events.Event;
import flash.media.ID3Info;
import flash.media.Sound;
import flash.net.NetStream;
/**
* Implements the player events
*/
class PlayerEvents extends Event
{
public static var ASPECT_RATIO = "onAspectRatio";
public static var MOUSE_SHOW = "onMouseShow";
public static var MOUSE_HIDE = "onMouseHide";
public static var FULLSCREEN = "onFullscreen";
public static var VOLUME_UP = "onVolumeUp";
public static var VOLUME_DOWN = "onVolumeDown";
public static var VOLUME_CHANGE= "onVolumeChange"; //Nuevo
public static var MUTE = "onMute";
public static var FORWARD = "onForward";
public static var REWIND = "onRewind";
public static var PLAY_PAUSE = "onPlayPause";
public static var SEEK = "onSeek";
public static var TIME = "onTimeUpdate";
public static var PROGRESS = "onProgress";
public static var BUFFERING = "onBuffering";
public static var NOT_BUFFERING = "onNotBuffering";
public static var CONNECTION_FAILED = "onConnectionFailed";
public static var CONNECTION_SUCCESS = "onConnectionSuccess";
public static var MEDIA_INITIALIZED = "onDataInitialized";
public static var PLAYBACK_FINISHED = "onPlaybackFinished";
public static var STOP_CLOSE = "onStopAndClose";
public static var RESIZE = "onResize";
public var name:String;
public var aspectRatio:Float;
public var duration:Float;
public var fullscreen:Bool;
public var mute:Bool;
public var volume:Float;
public var width:Float;
public var height:Float;
public var stream:NetStream;
public var sound:Sound;
public var time:Float;
public var id3Info:ID3Info;
public function new(type:String, bubbles:Bool=false, cancelable:Bool=false)
{
super(type, bubbles, cancelable);
fullscreen = false;
mute = false;
volume = 1.0;
duration = 0;
width = 0;
height = 0;
time = 0;
name = type;
}
}
v2.0.17~dfsg/src/jaris/Version.hx 0000644 0000000 0000000 00000002245 12625374554 015436 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris;
/**
* Actual jaris flv player version and date
*/
class Version
{
public static var NUMBER:String = "2.0.17";
public static var STATUS:String = "stable";
public static var DATE:String = "22";
public static var MONTH:String = "11";
public static var YEAR:String = "2015";
}
v2.0.17~dfsg/src/jaris/player/ 0000755 0000000 0000000 00000000000 12625374554 014741 5 ustar root root v2.0.17~dfsg/src/jaris/player/AspectRatio.hx 0000644 0000000 0000000 00000003071 12625374554 017521 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
/**
* Stores the player used aspect ratio constants
*/
class AspectRatio
{
public static var _1_1:Float = 1 / 1;
public static var _3_2:Float = 3 / 2;
public static var _4_3:Float = 4 / 3;
public static var _5_4:Float = 5 / 4;
public static var _14_9:Float = 14 / 9;
public static var _14_10:Float = 14 / 10;
public static var _16_9:Float = 16 / 9;
public static var _16_10:Float = 16 / 10;
/**
* Calculates the ratio for a given width and height
* @param width
* @param height
* @return aspect ratio
*/
public static function getAspectRatio(width:Float, height:Float):Float
{
return width / height;
}
}
v2.0.17~dfsg/src/jaris/player/UserSettings.hx 0000644 0000000 0000000 00000005437 12625374554 017752 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
import flash.net.SharedObject;
/**
* To store and retrieve user settings so the player can load them next time it loads.
* In this way player can remember user selected aspect ratio and volume.
*/
class UserSettings
{
private var _settings:SharedObject;
public function new()
{
_settings = SharedObject.getLocal("JarisPlayerUserSettings");
}
//{Methods
/**
* Deletes all user settings
*/
public function deleteSettings():Void
{
_settings.clear();
}
/**
* Checks if a user setting is available
* @param field The name of the setting
* @return true if is set false otherwise
*/
public function isSet(field:String):Bool
{
return Reflect.hasField(_settings.data, field);
}
//}
//{Properties Setters
/**
* Stores the volume value
* @param level
*/
public function setVolume(level:Float):Void
{
_settings.data.volume = level;
_settings.flush();
}
/**
* Stores the aspect ratio value
* @param aspect
*/
public function setAspectRatio(aspectratio:Float):Void
{
_settings.data.aspectratio = aspectratio;
_settings.flush();
}
//}
//{Properties Getters
/**
* The last user selected volume value
* @return Last user selected volume value or default if not set.
*/
public function getVolume():Float
{
if (!isSet("volume"))
{
return 1.0; //The maximum volume value
}
return _settings.data.volume;
}
/**
* The last user selected aspect ratio value
* @return Last user selected aspect ratio value or default if not set.
*/
public function getAspectRatio():Float
{
if (!isSet("aspectratio"))
{
return 0.0; //Equivalent to original
}
return _settings.data.aspectratio;
}
//}
}
v2.0.17~dfsg/src/jaris/player/Player.hx 0000644 0000000 0000000 00000144220 12625374554 016541 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageDisplayState;
import flash.events.AsyncErrorEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.FullScreenEvent;
import flash.events.IOErrorEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.NetStatusEvent;
import flash.events.ProgressEvent;
import flash.events.TimerEvent;
import flash.geom.Rectangle;
import flash.Lib;
import flash.media.ID3Info;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.URLRequest;
import flash.system.Capabilities;
import flash.system.Security;
import flash.ui.Keyboard;
import flash.ui.Mouse;
import flash.utils.Timer;
import jaris.events.PlayerEvents;
import jaris.utils.Utils;
import jaris.player.AspectRatio;
import jaris.player.UserSettings;
/**
* Jaris main video player
*/
class Player extends EventDispatcher
{
//{Member variables
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _connection:NetConnection;
private var _stream:NetStream;
private var _fullscreen:Bool;
private var _soundMuted:Bool;
private var _volume:Float;
private var _bufferTime:Float;
private var _mouseVisible:Bool;
private var _mediaLoaded:Bool;
private var _hideMouseTimer:Timer;
private var _checkAudioTimer:Timer;
private var _mediaSource:String;
private var _type:String;
private var _streamType:String;
private var _server:String; //For future use on rtmp
private var _sound:Sound;
private var _soundChannel:SoundChannel;
private var _id3Info:ID3Info;
private var _video:Video;
private var _videoWidth:Float;
private var _videoHeight:Float;
private var _videoMask:Sprite;
private var _videoQualityHigh:Bool;
private var _mediaDuration:Float;
private var _lastTime:Float;
private var _lastProgress:Float;
private var _isPlaying:Bool;
private var _aspectRatio:Float;
private var _currentAspectRatio:String;
private var _originalAspectRatio:Float;
private var _mediaEndReached:Bool;
private var _seekPoints:Array;
private var _downloadCompleted:Bool;
private var _startTime:Float;
private var _firstLoad:Bool;
private var _stopped:Bool;
private var _useHardWareScaling:Bool;
private var _youtubeLoader:Loader;
private var _userSettings:UserSettings;
//}
//{Constructor
public function new()
{
super();
//{Main Variables Init
_stage = Lib.current.stage;
_movieClip = Lib.current;
_mouseVisible = true;
_soundMuted = false;
_volume = 1.0;
_bufferTime = 10;
_fullscreen = false;
_mediaLoaded = false;
_hideMouseTimer = new Timer(1500);
_checkAudioTimer = new Timer(100);
_seekPoints = new Array();
_downloadCompleted = false;
_startTime = 0;
_firstLoad = true;
_stopped = false;
_videoQualityHigh = false;
_isPlaying = false;
_streamType = StreamType.FILE;
_type = InputType.VIDEO;
_server = "";
_currentAspectRatio = "original";
_aspectRatio = 0;
_lastTime = 0;
_lastProgress = 0;
_userSettings = new UserSettings();
//}
//{Initialize sound object
_sound = new Sound();
_sound.addEventListener(Event.COMPLETE, onSoundComplete);
_sound.addEventListener(Event.ID3, onSoundID3);
_sound.addEventListener(IOErrorEvent.IO_ERROR, onSoundIOError);
_sound.addEventListener(ProgressEvent.PROGRESS, onSoundProgress);
//}
//{Initialize video and connection objects
_connection = new NetConnection();
_connection.client = this;
_connection.connect(null);
_stream = new NetStream(_connection);
_video = new Video(_stage.stageWidth, _stage.stageHeight);
_movieClip.addChild(_video);
//}
//Video mask so that custom menu items work
_videoMask = new Sprite();
_movieClip.addChild(_videoMask);
//Set initial rendering to high quality
toggleQuality();
//{Initialize system event listeners
_movieClip.addEventListener(Event.ENTER_FRAME, onEnterFrame);
_stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
_stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreen);
_stage.addEventListener(Event.RESIZE, onResize);
_hideMouseTimer.addEventListener(TimerEvent.TIMER, hideMouseTimer);
_checkAudioTimer.addEventListener(TimerEvent.TIMER, checkAudioTimer);
_connection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
_connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
//}
}
//}
//{Timers
/**
* Timer that hides the mouse pointer when it is idle and dispatch the PlayerEvents.MOUSE_HIDE
* @param event
*/
private function hideMouseTimer(event:TimerEvent):Void
{
if (_fullscreen)
{
if (_mouseVisible)
{
_mouseVisible = false;
}
else
{
Mouse.hide();
callEvents(PlayerEvents.MOUSE_HIDE);
_hideMouseTimer.stop();
}
}
}
/**
* To check if the sound finished playing
* @param event
*/
private function checkAudioTimer(event:TimerEvent):Void
{
if (_soundChannel.position + 100 >= _sound.length)
{
_isPlaying = false;
_mediaEndReached = true;
callEvents(PlayerEvents.PLAYBACK_FINISHED);
_checkAudioTimer.stop();
}
}
//}
//{Events
/**
* Callback after bandwidth calculation for rtmp streams
*/
private function onBWDone():Void
{
//Need to study this more
}
/**
* Triggers error event on rtmp connections
* @param event
*/
private function onAsyncError(event:AsyncErrorEvent):Void
{
//TODO: Should trigger event for controls to display error message
//trace(event.error);
}
/**
* Checks if connection failed or succeed
* @param event
*/
private function onNetStatus(event:NetStatusEvent):Void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success":
if (_streamType == StreamType.RTMP)
{
_stream = new NetStream(_connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
_stream.bufferTime = 10;
//_stream.play(Utils.rtmpSourceParser(_mediaSource), true);
_stream.play(_mediaSource);
_stream.client = this;
if(_type == InputType.VIDEO) {_video.attachNetStream(_stream); }
}
callEvents(PlayerEvents.CONNECTION_SUCCESS);
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + _mediaSource); //Replace with a dispatch for error event
callEvents(PlayerEvents.CONNECTION_FAILED);
case "NetStream.Play.Stop":
if (_streamType != StreamType.RTMP)
{
if (_isPlaying) { _stream.togglePause(); }
_isPlaying = false;
_mediaEndReached = true;
callEvents(PlayerEvents.PLAYBACK_FINISHED);
}
case "NetStream.Play.Start":
_isPlaying = true;
_mediaEndReached = false;
if (_stream.bytesLoaded != _stream.bytesTotal || _streamType == StreamType.RTMP)
{
callEvents(PlayerEvents.BUFFERING);
}
case "NetStream.Seek.Notify":
_mediaEndReached = false;
if (_streamType == StreamType.RTMP)
{
_isPlaying = true;
callEvents(PlayerEvents.PLAY_PAUSE);
callEvents(PlayerEvents.BUFFERING);
}
case "NetStream.Buffer.Empty":
if (_stream.bytesLoaded != _stream.bytesTotal)
{
callEvents(PlayerEvents.BUFFERING);
}
case "NetStream.Buffer.Full":
callEvents(PlayerEvents.NOT_BUFFERING);
case "NetStream.Buffer.Flush":
if (_stream.bytesLoaded == _stream.bytesTotal)
{
_downloadCompleted = true;
}
}
}
/**
* Proccess keyboard shortcuts
* @param event
*/
private function onKeyDown(event:KeyboardEvent):Void
{
var F_KEY:UInt = 70;
var M_KEY:UInt = 77;
var X_KEY:UInt = 88;
if(event.keyCode == Keyboard.TAB)
{
toggleAspectRatio();
}
else if(event.keyCode == F_KEY)
{
toggleFullscreen();
}
else if(event.keyCode == M_KEY)
{
toggleMute();
}
else if(event.keyCode == Keyboard.UP)
{
volumeUp();
}
else if(event.keyCode == Keyboard.DOWN)
{
volumeDown();
}
else if(event.keyCode == Keyboard.RIGHT)
{
forward();
}
else if(event.keyCode == Keyboard.LEFT)
{
rewind();
}
else if(event.keyCode == Keyboard.SPACE)
{
togglePlay();
}
else if(event.keyCode == X_KEY)
{
stopAndClose();
}
}
/**
* IF player is full screen shows the mouse when gets hide
* @param event
*/
private function onMouseMove(event:MouseEvent):Void
{
if (_fullscreen && !_mouseVisible)
{
if (!_hideMouseTimer.running)
{
_hideMouseTimer.start();
}
_mouseVisible = true;
Mouse.show();
callEvents(PlayerEvents.MOUSE_SHOW);
}
}
/**
* Resize video player
* @param event
*/
private function onResize(event:Event):Void
{
resizeAndCenterPlayer();
}
/**
* Dispath a full screen event to listeners as redraw player an takes care of some other aspects
* @param event
*/
private function onFullScreen(event:FullScreenEvent):Void
{
_fullscreen = event.fullScreen;
if (!event.fullScreen)
{
Mouse.show();
callEvents(PlayerEvents.MOUSE_SHOW);
_mouseVisible = true;
}
else
{
_mouseVisible = true;
_hideMouseTimer.start();
}
resizeAndCenterPlayer();
callEvents(PlayerEvents.FULLSCREEN);
}
/**
* Sits for any cue points available
* @param data
* @note Planned future implementation
*/
private function onCuePoint(data:Dynamic):Void
{
}
/**
* After a video is loaded this callback gets the video information at start and stores it on variables
* @param data
*/
private function onMetaData(data:Dynamic):Void
{
if (_firstLoad)
{
_isPlaying = true;
_firstLoad = false;
if (data.width)
{
_videoWidth = data.width;
_videoHeight = data.height;
}
else
{
_videoWidth = _video.width;
_videoHeight = _video.height;
}
//Store seekpoints times
if (data.hasOwnProperty("seekpoints")) //MP4
{
for (position in Reflect.fields(data.seekpoints))
{
_seekPoints.push(Reflect.field(data.seekpoints, position).time);
}
}
else if (data.hasOwnProperty("keyframes")) //FLV
{
for (position in Reflect.fields(data.keyframes.times))
{
_seekPoints.push(Reflect.field(data.keyframes.times, position));
}
}
_mediaLoaded = true;
_mediaDuration = data.duration;
_originalAspectRatio = AspectRatio.getAspectRatio(_videoWidth, _videoHeight);
if (_aspectRatio <= 0)
{
_aspectRatio = _originalAspectRatio;
}
callEvents(PlayerEvents.MEDIA_INITIALIZED);
resizeAndCenterPlayer();
//Retrieve the volume that user selected last time
setVolume(_userSettings.getVolume());
}
}
/**
* Dummy function invoked for pseudostream servers
* @param data
*/
private function onLastSecond(data:Dynamic):Void
{
trace("last second pseudostream");
}
/**
* Broadcast Timeupdate and Duration
*/
private function onEnterFrame(event:Event):Void
{
if (getDuration() > 0 && _lastTime != getCurrentTime())
{
_lastTime = getCurrentTime();
callEvents(PlayerEvents.TIME);
}
if (getBytesLoaded() > 0 && _lastProgress < getBytesLoaded())
{
_lastProgress = getBytesLoaded();
callEvents(PlayerEvents.PROGRESS);
}
}
/**
* Triggers when playbacks end on rtmp streaming server
*/
private function onPlayStatus(info:Dynamic):Void
{
_isPlaying = false;
_mediaEndReached = true;
callEvents(PlayerEvents.PLAYBACK_FINISHED);
}
/**
* When sound finished downloading
* @param event
*/
private function onSoundComplete(event:Event)
{
_mediaDuration = _sound.length / 1000;
_downloadCompleted = true;
callEvents(PlayerEvents.MEDIA_INITIALIZED);
}
/**
* Mimic stream onMetaData
* @param event
*/
private function onSoundID3(event:Event)
{
if (_firstLoad)
{
_soundChannel = _sound.play();
_checkAudioTimer.start();
_isPlaying = true;
_firstLoad = false;
_mediaLoaded = true;
_mediaDuration = ((_sound.bytesTotal / _sound.bytesLoaded) * _sound.length) / 1000;
_aspectRatio = AspectRatio.getAspectRatio(_videoWidth, _videoHeight);
_originalAspectRatio = _aspectRatio;
_id3Info = _sound.id3;
callEvents(PlayerEvents.CONNECTION_SUCCESS);
callEvents(PlayerEvents.MEDIA_INITIALIZED);
resizeAndCenterPlayer();
//Retrieve the volume that user selected last time
setVolume(_userSettings.getVolume());
}
}
/**
* Dispatch connection failed event on error
* @param event
*/
private function onSoundIOError(event:IOErrorEvent)
{
callEvents(PlayerEvents.CONNECTION_FAILED);
}
/**
* Monitor sound download progress
* @param event
*/
private function onSoundProgress(event:ProgressEvent)
{
if (_sound.isBuffering)
{
callEvents(PlayerEvents.BUFFERING);
}
else
{
callEvents(PlayerEvents.NOT_BUFFERING);
}
_mediaDuration = ((_sound.bytesTotal / _sound.bytesLoaded) * _sound.length) / 1000;
callEvents(PlayerEvents.MEDIA_INITIALIZED);
}
/**
* Initializes the youtube loader object
* @param event
*/
private function onYouTubeLoaderInit(event:Event):Void
{
_youtubeLoader.content.addEventListener("onReady", onYoutubeReady);
_youtubeLoader.content.addEventListener("onError", onYoutubeError);
_youtubeLoader.content.addEventListener("onStateChange", onYoutubeStateChange);
_youtubeLoader.content.addEventListener("onPlaybackQualityChange", onYoutubePlaybackQualityChange);
}
/**
* This event is fired when the player is loaded and initialized, meaning it is ready to receive API calls.
*/
private function onYoutubeReady(event:Event):Void
{
_movieClip.addChild(_youtubeLoader.content);
_movieClip.setChildIndex(_youtubeLoader.content, 0);
Reflect.field(_youtubeLoader.content, "setSize")(_stage.stageWidth, _stage.stageHeight);
Reflect.field(_youtubeLoader.content, "loadVideoByUrl")(Utils.youtubeSourceParse(_mediaSource));
callEvents(PlayerEvents.BUFFERING);
}
/**
* This event is fired whenever the player's state changes. Possible values are unstarted (-1), ended (0),
* playing (1), paused (2), buffering (3), video cued (5). When the SWF is first loaded it will broadcast
* an unstarted (-1) event. When the video is cued and ready to play it will broadcast a video cued event (5).
* @param event
*/
private function onYoutubeStateChange(event:Event):Void
{
var status:UInt = Std.parseInt(Reflect.field(event, "data"));
switch(status)
{
case -1:
callEvents(PlayerEvents.BUFFERING);
case 0:
_isPlaying = false;
_mediaEndReached = true;
callEvents(PlayerEvents.PLAYBACK_FINISHED);
case 1:
if (_firstLoad)
{
_isPlaying = true;
_videoWidth = _stage.stageWidth;
_videoHeight = _stage.stageHeight;
_firstLoad = false;
_mediaLoaded = true;
_mediaDuration = Reflect.field(_youtubeLoader.content, "getDuration")();
_aspectRatio = AspectRatio.getAspectRatio(_videoWidth, _videoHeight);
_originalAspectRatio = _aspectRatio;
callEvents(PlayerEvents.CONNECTION_SUCCESS);
callEvents(PlayerEvents.MEDIA_INITIALIZED);
resizeAndCenterPlayer();
//Retrieve the volume that user selected last time
setVolume(_userSettings.getVolume());
}
callEvents(PlayerEvents.NOT_BUFFERING);
case 2:
callEvents(PlayerEvents.NOT_BUFFERING);
case 3:
callEvents(PlayerEvents.BUFFERING);
case 5:
callEvents(PlayerEvents.NOT_BUFFERING);
}
}
/**
* This event is fired whenever the video playback quality changes. For example, if you call the
* setPlaybackQuality(suggestedQuality) function, this event will fire if the playback quality actually
* changes. Your code should respond to the event and should not assume that the quality will automatically
* change when the setPlaybackQuality(suggestedQuality) function is called. Similarly, your code should not
* assume that playback quality will only change as a result of an explicit call to setPlaybackQuality or any
* other function that allows you to set a suggested playback quality.
*
* The value that the event broadcasts is the new playback quality. Possible values are "small", "medium",
* "large" and "hd720".
* @param event
*/
private function onYoutubePlaybackQualityChange(event:Event):Void
{
//trace(Reflect.field(event, "data"));
}
/**
* This event is fired when an error in the player occurs. The possible error codes are 100, 101,
* and 150. The 100 error code is broadcast when the video requested is not found. This occurs when
* a video has been removed (for any reason), or it has been marked as private. The 101 error code is
* broadcast when the video requested does not allow playback in the embedded players. The error code
* 150 is the same as 101, it's just 101 in disguise!
* @param event
*/
private function onYoutubeError(event:Event):Void
{
trace(Reflect.field(event, "data"));
}
//}
//{Private Methods
/**
* Function used each time is needed to dispatch an event
* @param type
*/
private function callEvents(type:String):Void
{
var playerEvent:PlayerEvents = new PlayerEvents(type, true);
playerEvent.aspectRatio = getAspectRatio();
playerEvent.duration = getDuration();
playerEvent.fullscreen = isFullscreen();
playerEvent.mute = getMute();
playerEvent.volume = getVolume();
playerEvent.width = _video.width;
playerEvent.height = _video.height;
playerEvent.stream = getNetStream();
playerEvent.sound = getSound();
playerEvent.time = getCurrentTime();
playerEvent.id3Info = getId3Info();
dispatchEvent(playerEvent);
}
/**
* Reposition and resizes the video player to fit on screen
*/
private function resizeAndCenterPlayer():Void
{
if (_streamType != StreamType.YOUTUBE)
{
_video.height = _stage.stageHeight;
_video.width = _video.height * _aspectRatio;
_video.x = (_stage.stageWidth / 2) - (_video.width / 2);
_video.y = 0;
if (_video.width > _stage.stageWidth && _aspectRatio == _originalAspectRatio)
{
var aspectRatio:Float = _videoHeight / _videoWidth;
_video.width = _stage.stageWidth;
_video.height = aspectRatio * _video.width;
_video.x = 0;
_video.y = (_stage.stageHeight / 2) - (_video.height / 2);
}
_videoMask.graphics.clear();
_videoMask.graphics.lineStyle();
_videoMask.graphics.beginFill(0x000000, 0);
_videoMask.graphics.drawRect(_video.x, _video.y, _video.width, _video.height);
_videoMask.graphics.endFill();
}
else
{
Reflect.field(_youtubeLoader.content, "setSize")(_stage.stageWidth, _stage.stageHeight);
_videoMask.graphics.clear();
_videoMask.graphics.lineStyle();
_videoMask.graphics.beginFill(0x000000, 0);
_videoMask.graphics.drawRect(0, 0, _stage.stageWidth, _stage.stageHeight);
_videoMask.graphics.endFill();
}
callEvents(PlayerEvents.RESIZE);
}
/**
* Check the best seek point available if the seekpoints array is available
* @param time time in seconds
* @return best seek point in seconds or given one if no seekpoints array is available
*/
private function getBestSeekPoint(time:Float):Float
{
if (_seekPoints.length > 0)
{
var timeOne:String="0";
var timeTwo:String="0";
for(prop in Reflect.fields(_seekPoints))
{
if(Reflect.field(_seekPoints,prop) < time)
{
timeOne = prop;
}
else
{
timeTwo = prop;
break;
}
}
if(time - _seekPoints[Std.parseInt(timeOne)] < _seekPoints[Std.parseInt(timeTwo)] - time)
{
return _seekPoints[Std.parseInt(timeOne)];
}
else
{
return _seekPoints[Std.parseInt(timeTwo)];
}
}
return time;
}
/**
* Checks if the given seek time is already buffered
* @param time time in seconds
* @return true if can seek false if not in buffer
*/
private function canSeek(time:Float):Bool
{
if (_type == InputType.VIDEO)
{
time = getBestSeekPoint(time);
}
var cacheTotal = Math.floor((getDuration() - _startTime) * (getBytesLoaded() / getBytesTotal())) - 1;
if(time >= _startTime && time < _startTime + cacheTotal)
{
return true;
}
return false;
}
//}
//{Public methods
/**
* Loads a video and starts playing it
* @param video video url to load
*/
public function load(source:String, type:String="video", streamType:String="file", server:String=""):Void
{
stopAndClose();
_type = type;
_streamType = streamType;
_mediaSource = source;
_stopped = false;
_mediaLoaded = false;
_firstLoad = true;
_startTime = 0;
_downloadCompleted = false;
_seekPoints = new Array();
_server = server;
callEvents(PlayerEvents.BUFFERING);
if (_streamType == StreamType.YOUTUBE)
{
Security.allowDomain("*");
Security.allowDomain("www.youtube.com");
Security.allowDomain("youtube.com");
Security.allowDomain("s.ytimg.com");
Security.allowDomain("i.ytimg.com");
_youtubeLoader = new Loader();
_youtubeLoader.contentLoaderInfo.addEventListener(Event.INIT, onYouTubeLoaderInit);
_youtubeLoader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
}
else if (_type == InputType.VIDEO && (_streamType == StreamType.FILE || _streamType == StreamType.PSEUDOSTREAM))
{
_connection.connect(null);
_stream = new NetStream(_connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
_stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, doAsyncError);
_stream.bufferTime = _bufferTime;
_stream.play(source);
_stream.client = this;
_video.attachNetStream(_stream);
}
else if (_type == InputType.VIDEO && _streamType == StreamType.RTMP)
{
_connection.connect(_server);
}
else if (_type == InputType.AUDIO && _streamType == StreamType.RTMP)
{
_connection.connect(_server);
}
else if(_type == InputType.AUDIO && _streamType == StreamType.FILE)
{
_sound.load(new URLRequest(source));
}
}
private function doAsyncError(e:AsyncErrorEvent) : Void
{
// Do nothing, to block the exception.
}
/**
* Closes the connection and makes player available for another video
*/
public function stopAndClose():Void
{
if (_mediaLoaded)
{
_mediaLoaded = false;
_isPlaying = false;
_stopped = true;
_startTime = 0;
if (_streamType == StreamType.YOUTUBE)
{
Reflect.field(_youtubeLoader.content, "destroy")();
}
else if (_type == InputType.VIDEO)
{
_stream.close();
}
else
{
_soundChannel.stop();
_sound.close();
}
}
callEvents(PlayerEvents.STOP_CLOSE);
}
/**
* Seeks 8 seconds forward from the current position.
* @return current play time after forward
*/
public function forward():Float
{
var seekTime = (getCurrentTime() + 8) + _startTime;
if (getDuration() > seekTime)
{
seekTime = seek(seekTime);
}
return seekTime;
}
/**
* Seeks 8 seconds back from the current position.
* @return current play time after rewind
*/
public function rewind():Float
{
var seekTime = (getCurrentTime() - 8) + _startTime;
if (seekTime >= _startTime)
{
seekTime = seek(seekTime);
}
return seekTime;
}
/**
* Seeks video player to a given time in seconds
* @param seekTime time in seconds to seek
* @return current play time after seeking
*/
public function seek(seekTime:Float):Float
{
if (_startTime <= 1 && _downloadCompleted)
{
if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_stream.seek(seekTime);
}
else if (_type == InputType.AUDIO)
{
_soundChannel.stop();
_soundChannel = _sound.play(seekTime * 1000);
if (!_isPlaying)
{
_soundChannel.stop();
}
setVolume(_userSettings.getVolume());
}
}
else if(_seekPoints.length > 0 && _streamType == StreamType.PSEUDOSTREAM)
{
seekTime = getBestSeekPoint(seekTime);
if (canSeek(seekTime))
{
_stream.seek(seekTime - _startTime);
}
else if(seekTime != _startTime)
{
_startTime = seekTime;
var url:String;
if (_mediaSource.indexOf("?") != -1)
{
url = _mediaSource + "&start=" + seekTime;
}
else
{
url = _mediaSource + "?start=" + seekTime;
}
_stream.play(url);
}
}
else if (_streamType == StreamType.YOUTUBE)
{
if (!canSeek(seekTime))
{
_startTime = seekTime;
Reflect.field(_youtubeLoader.content, "seekTo")(seekTime);
}
else
{
Reflect.field(_youtubeLoader.content, "seekTo")(seekTime);
}
}
else if (_streamType == StreamType.RTMP)
{
// seekTime = getBestSeekPoint(seekTime); //Not Needed?
_stream.seek(seekTime);
}
else if(canSeek(seekTime))
{
if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_stream.seek(seekTime);
}
else if (_type == InputType.AUDIO)
{
_soundChannel.stop();
_soundChannel = _sound.play(seekTime * 1000);
if (!_isPlaying)
{
_soundChannel.stop();
}
setVolume(_userSettings.getVolume());
}
}
callEvents(PlayerEvents.SEEK);
return seekTime;
}
/**
* To check wheter the media is playing
* @return true if is playing false otherwise
*/
public function isPlaying():Bool
{
return _isPlaying;
}
/**
* Cycle betewen aspect ratios
* @return new aspect ratio in use
*/
public function toggleAspectRatio():Float
{
switch(_currentAspectRatio)
{
case "original":
_aspectRatio = AspectRatio._1_1;
_currentAspectRatio = "1:1";
case "1:1":
_aspectRatio = AspectRatio._3_2;
_currentAspectRatio = "3:2";
case "3:2":
_aspectRatio = AspectRatio._4_3;
_currentAspectRatio = "4:3";
case "4:3":
_aspectRatio = AspectRatio._5_4;
_currentAspectRatio = "5:4";
case "5:4":
_aspectRatio = AspectRatio._14_9;
_currentAspectRatio = "14:9";
case "14:9":
_aspectRatio = AspectRatio._14_10;
_currentAspectRatio = "14:10";
case "14:10":
_aspectRatio = AspectRatio._16_9;
_currentAspectRatio = "16:9";
case "16:9":
_aspectRatio = AspectRatio._16_10;
_currentAspectRatio = "16:10";
case "16:10":
_aspectRatio = _originalAspectRatio;
_currentAspectRatio = "original";
default:
_aspectRatio = _originalAspectRatio;
_currentAspectRatio = "original";
}
resizeAndCenterPlayer();
callEvents(PlayerEvents.ASPECT_RATIO);
//Store aspect ratio into user settings
if (_aspectRatio == _originalAspectRatio)
{
_userSettings.setAspectRatio(0.0);
}
else
{
_userSettings.setAspectRatio(_aspectRatio);
}
return _aspectRatio;
}
/**
* Swithces between play and pause
*/
public function togglePlay():Bool
{
if (_mediaLoaded)
{
if (_mediaEndReached)
{
_mediaEndReached = false;
if (_streamType == StreamType.YOUTUBE)
{
Reflect.field(_youtubeLoader.content, "seekTo")(0);
Reflect.field(_youtubeLoader.content, "playVideo")();
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_stream.seek(0);
_stream.togglePause();
}
else if (_type == InputType.AUDIO)
{
_checkAudioTimer.start();
_soundChannel = _sound.play();
setVolume(_userSettings.getVolume());
}
}
else if (_mediaLoaded)
{
if (_streamType == StreamType.YOUTUBE)
{
if (_isPlaying)
{
Reflect.field(_youtubeLoader.content, "pauseVideo")();
}
else
{
Reflect.field(_youtubeLoader.content, "playVideo")();
}
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_stream.togglePause();
}
else if (_type == InputType.AUDIO)
{
if (_isPlaying)
{
_soundChannel.stop();
}
else
{
//If end of audio reached start from beggining
if (_soundChannel.position + 100 >= _sound.length)
{
_soundChannel = _sound.play();
}
else
{
_soundChannel = _sound.play(_soundChannel.position);
}
setVolume(_userSettings.getVolume());
}
}
}
else if (_stopped)
{
load(_mediaSource, _type, _streamType, _server);
}
_isPlaying = !_isPlaying;
callEvents(PlayerEvents.PLAY_PAUSE);
return _isPlaying;
}
else if(_mediaSource != "")
{
load(_mediaSource, _type, _streamType, _server);
callEvents(PlayerEvents.BUFFERING);
return true;
}
callEvents(PlayerEvents.PLAY_PAUSE);
return false;
}
/**
* Switches on or off fullscreen
* @return true if fullscreen otherwise false
*/
public function toggleFullscreen():Bool
{
if (_fullscreen)
{
_stage.displayState = StageDisplayState.NORMAL;
_stage.focus = _stage;
return false;
}
else
{
if (_useHardWareScaling)
{
//Match full screen aspec ratio to desktop
var aspectRatio = Capabilities.screenResolutionY / Capabilities.screenResolutionX;
_stage.fullScreenSourceRect = new Rectangle(0, 0, _videoWidth, _videoWidth * aspectRatio);
}
else
{
//Use desktop resolution
_stage.fullScreenSourceRect = new Rectangle(0, 0, Capabilities.screenResolutionX ,Capabilities.screenResolutionY);
}
_stage.displayState = StageDisplayState.FULL_SCREEN;
_stage.focus = _stage;
return true;
}
}
/**
* Toggles betewen high and low quality image rendering
* @return true if quality high false otherwise
*/
public function toggleQuality():Bool
{
if (_videoQualityHigh)
{
_video.smoothing = false;
_video.deblocking = 1;
}
else
{
_video.smoothing = true;
_video.deblocking = 5;
}
_videoQualityHigh = _videoQualityHigh?false:true;
return _videoQualityHigh;
}
/**
* Mutes or unmutes the sound
* @return true if muted false if unmuted
*/
public function toggleMute():Bool
{
var soundTransform:SoundTransform = new SoundTransform();
var isMute:Bool;
//unmute sound
if (_soundMuted)
{
_soundMuted = false;
if (_volume > 0)
{
soundTransform.volume = _volume;
}
else
{
_volume = 1.0;
soundTransform.volume = _volume;
}
isMute = false;
}
//mute sound
else
{
_soundMuted = true;
_volume = _stream.soundTransform.volume;
soundTransform.volume = 0;
_stream.soundTransform = soundTransform;
isMute = true;
}
if (_streamType == StreamType.YOUTUBE)
{
Reflect.field(_youtubeLoader.content, "setVolume")(soundTransform.volume * 100);
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_stream.soundTransform = soundTransform;
}
else if (_type == InputType.AUDIO)
{
_soundChannel.soundTransform = soundTransform;
setVolume(_userSettings.getVolume());
}
callEvents(PlayerEvents.MUTE);
return isMute;
}
/**
* Check if player is running on fullscreen mode
* @return true if fullscreen false if not
*/
public function isFullscreen():Bool
{
return _stage.displayState == StageDisplayState.FULL_SCREEN;
}
/**
* Raises the volume
* @return volume value after raising
*/
public function volumeUp():Float
{
var soundTransform:SoundTransform = new SoundTransform();
if (_soundMuted)
{
_soundMuted = false;
}
//raise volume if not already at max
if (_volume < 1)
{
if (_streamType == StreamType.YOUTUBE)
{
_volume = (Reflect.field(_youtubeLoader.content, "getVolume")() + 10) / 100;
Reflect.field(_youtubeLoader.content, "setVolume")(_volume * 100);
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_volume = _stream.soundTransform.volume + (10/100);
soundTransform.volume = _volume;
_stream.soundTransform = soundTransform;
}
else if (_type == InputType.AUDIO)
{
_volume = _soundChannel.soundTransform.volume + (10/100);
soundTransform.volume = _volume;
_soundChannel.soundTransform = soundTransform;
}
}
//reset volume to 1.0 if already reached max
if (_volume >= 1)
{
_volume = 1.0;
}
//Store volume into user settings
_userSettings.setVolume(_volume);
callEvents(PlayerEvents.VOLUME_UP);
return _volume;
}
/**
* Lower the volume
* @return volume value after lowering
*/
public function volumeDown():Float
{
var soundTransform:SoundTransform = new SoundTransform();
//lower sound
if(!_soundMuted)
{
if (_streamType == StreamType.YOUTUBE)
{
_volume = (Reflect.field(_youtubeLoader.content, "getVolume")() - 10) / 100;
Reflect.field(_youtubeLoader.content, "setVolume")(_volume * 100);
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_volume = _stream.soundTransform.volume - (10/100);
soundTransform.volume = _volume;
_stream.soundTransform = soundTransform;
}
else if (_type == InputType.AUDIO)
{
_volume = _soundChannel.soundTransform.volume - (10/100);
soundTransform.volume = _volume;
_soundChannel.soundTransform = soundTransform;
}
//if volume reached min is muted
if (_volume <= 0)
{
_soundMuted = true;
_volume = 0;
}
}
//Store volume into user settings
_userSettings.setVolume(_volume);
callEvents(PlayerEvents.VOLUME_DOWN);
return _volume;
}
//}
//{Setters
/**
* Set input type
* @param type Allowable values are audio, video
*/
public function setType(type:String):Void
{
_type = type;
}
/**
* Set streaming type
* @param streamType Allowable values are file, http, rmtp
*/
public function setStreamType(streamType:String):Void
{
_streamType = streamType;
}
/**
* Sets the server url for rtmp streams
* @param server
*/
public function setServer(server:String):Void
{
_server = server;
}
/**
* To set the video source in case we dont want to start downloading at first so when use tooglePlay the
* media is loaded automatically
* @param source
*/
public function setSource(source):Void
{
_mediaSource = source;
}
/**
* Changes the current volume
* @param volume
*/
public function setVolume(volume:Float):Void
{
var soundTransform:SoundTransform = new SoundTransform();
if (volume > _volume) {
callEvents(PlayerEvents.VOLUME_UP);
}
if (volume < _volume) {
callEvents(PlayerEvents.VOLUME_DOWN);
}
if (volume > 0)
{
_soundMuted = false;
_volume = volume;
}
else
{
_soundMuted = true;
_volume = 1.0;
}
soundTransform.volume = volume;
if (!_firstLoad) //To prevent errors if objects aren't initialized
{
if (_streamType == StreamType.YOUTUBE)
{
Reflect.field(_youtubeLoader.content, "setVolume")(soundTransform.volume * 100);
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
_stream.soundTransform = soundTransform;
}
else if (_type == InputType.AUDIO)
{
_soundChannel.soundTransform = soundTransform;
}
}
//Store volume into user settings
_userSettings.setVolume(_volume);
callEvents(PlayerEvents.VOLUME_CHANGE);
}
/**
* Changes the buffer time for local and pseudo streaming
* @param time in seconds
*/
public function setBufferTime(time:Float):Void
{
if (time > 0)
{
_bufferTime = time;
}
}
/**
* Changes the aspec ratio of current playing media and resizes video player
* @param aspectRatio new aspect ratio value
*/
public function setAspectRatio(aspectRatio:Float):Void
{
_aspectRatio = aspectRatio;
switch(_aspectRatio)
{
case 0.0:
_currentAspectRatio = "original";
case AspectRatio._1_1:
_currentAspectRatio = "1:1";
case AspectRatio._3_2:
_currentAspectRatio = "3:2";
case AspectRatio._4_3:
_currentAspectRatio = "4:3";
case AspectRatio._5_4:
_currentAspectRatio = "5:4";
case AspectRatio._14_9:
_currentAspectRatio = "14:9";
case AspectRatio._14_10:
_currentAspectRatio = "14:10";
case AspectRatio._16_9:
_currentAspectRatio = "16:9";
case AspectRatio._16_10:
_currentAspectRatio = "16:10";
}
resizeAndCenterPlayer();
//Store aspect ratio into user settings
_userSettings.setAspectRatio(_aspectRatio);
}
/**
* Enable or disable hardware scaling
* @param value true to enable false to disable
*/
public function setHardwareScaling(value:Bool):Void
{
_useHardWareScaling = value;
}
//}
//{Getters
/**
* Gets the volume amount 0.0 to 1.0
* @return
*/
public function getVolume():Float
{
return _volume;
}
/**
* The current aspect ratio of the loaded Player
* @return
*/
public function getAspectRatio():Float
{
return _aspectRatio;
}
/**
* The current aspect ratio of the loaded Player in string format
* @return
*/
public function getAspectRatioString():String
{
return _currentAspectRatio;
}
/**
* Original aspect ratio of the video
* @return original aspect ratio
*/
public function getOriginalAspectRatio():Float
{
return _originalAspectRatio;
}
/**
* Total duration time of the loaded media
* @return time in seconds
*/
public function getDuration():Float
{
return _mediaDuration;
}
/**
* The time in seconds where the player started downloading
* @return time in seconds
*/
public function getStartTime():Float
{
return _startTime;
}
/**
* The stream associated with the player
* @return netstream object
*/
public function getNetStream():NetStream
{
return _stream;
}
/**
* Video object associated to the player
* @return video object for further manipulation
*/
public function getVideo():Video
{
return _video;
}
/**
* Sound object associated to the player
* @return sound object for further manipulation
*/
public function getSound():Sound
{
return _sound;
}
/**
* The id3 info of sound object
* @return
*/
public function getId3Info():ID3Info
{
return _id3Info;
}
/**
* The current sound state
* @return true if mute otherwise false
*/
public function getMute():Bool
{
return _soundMuted;
}
/**
* The amount of total bytes
* @return amount of bytes
*/
public function getBytesTotal():Float
{
var bytesTotal:Float = 0;
if (_streamType == StreamType.YOUTUBE)
{
if(_youtubeLoader != null && _mediaLoaded)
bytesTotal = Reflect.field(_youtubeLoader.content, "getVideoBytesTotal")();
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
bytesTotal = _stream.bytesTotal;
}
else if (_type == InputType.AUDIO)
{
bytesTotal = _sound.bytesTotal;
}
return bytesTotal;
}
/**
* The amount of bytes loaded
* @return amount of bytes
*/
public function getBytesLoaded():Float
{
var bytesLoaded:Float = 0;
if (_streamType == StreamType.YOUTUBE)
{
if(_youtubeLoader != null && _mediaLoaded)
bytesLoaded = Reflect.field(_youtubeLoader.content, "getVideoBytesLoaded")();
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
bytesLoaded = _stream.bytesLoaded;
}
else if (_type == InputType.AUDIO)
{
bytesLoaded = _sound.bytesLoaded;
}
return bytesLoaded;
}
/**
* Current playing file type
* @return audio or video
*/
public function getType():String
{
return _type;
}
/**
* The stream method for the current playing media
* @return
*/
public function getStreamType():String
{
return _streamType;
}
/**
* The server url for current rtmp stream
* @return
*/
public function getServer():String
{
return _server;
}
/**
* To check current quality mode
* @return true if high quality false if low
*/
public function getQuality():Bool
{
return _videoQualityHigh;
}
/**
* The current playing time
* @return current playing time in seconds
*/
public function getCurrentTime():Float
{
var time:Float = 0;
if (_streamType == StreamType.YOUTUBE)
{
if(_youtubeLoader != null)
{
time = Reflect.field(_youtubeLoader.content, "getCurrentTime")();
}
else
{
time = 0;
}
}
else if (_streamType == StreamType.PSEUDOSTREAM)
{
time = getStartTime() + _stream.time;
}
else if (_type == InputType.VIDEO || _streamType == StreamType.RTMP)
{
time = _stream.time;
}
else if (_type == InputType.AUDIO)
{
if(_soundChannel != null)
{
time = _soundChannel.position / 1000;
}
else
{
time = 0;
}
}
return time;
}
//}
}
v2.0.17~dfsg/src/jaris/player/JsApi.hx 0000755 0000000 0000000 00000016445 12625374554 016325 0 ustar root root /**
* @author Sascha Kluger
* @copyright 2010 Jefferson González, Sascha Kluger
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
//{Libraries
import flash.system.Capabilities;
import flash.system.Security;
import flash.external.ExternalInterface;
import flash.display.GradientType;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.Matrix;
import flash.Lib;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.net.NetStream;
import flash.geom.Rectangle;
import flash.net.ObjectEncoding;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.utils.Timer;
import jaris.animation.Animation;
import jaris.display.Loader;
import jaris.events.PlayerEvents;
import jaris.player.controls.AspectRatioIcon;
import jaris.player.controls.FullscreenIcon;
import jaris.player.controls.PauseIcon;
import jaris.player.controls.PlayIcon;
import jaris.player.controls.VolumeIcon;
import jaris.player.Player;
import flash.display.Sprite;
import flash.display.Stage;
import jaris.utils.Utils;
//}
/**
* Default controls for jaris player
*/
class JsApi extends MovieClip {
//{Member Variables
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _player:Player;
private var _isBuffering:Bool;
private var _percentLoaded:Float;
private var _externalListeners:Map;
//}
//{Constructor
public function new(player:Player)
{
super();
_externalListeners = new Map();
Security.allowDomain("*");
//{Main variables
// _stage = Lib.current.stage;
// _movieClip = Lib.current;
_player = player;
_player.addEventListener(PlayerEvents.MOUSE_HIDE, onPlayerEvent);
_player.addEventListener(PlayerEvents.MOUSE_SHOW, onPlayerEvent);
_player.addEventListener(PlayerEvents.MEDIA_INITIALIZED, onPlayerEvent);
_player.addEventListener(PlayerEvents.BUFFERING, onPlayerEvent);
_player.addEventListener(PlayerEvents.NOT_BUFFERING, onPlayerEvent);
_player.addEventListener(PlayerEvents.RESIZE, onPlayerEvent);
_player.addEventListener(PlayerEvents.PLAY_PAUSE, onPlayerEvent);
_player.addEventListener(PlayerEvents.PLAYBACK_FINISHED, onPlayerEvent);
_player.addEventListener(PlayerEvents.CONNECTION_FAILED, onPlayerEvent);
_player.addEventListener(PlayerEvents.ASPECT_RATIO, onPlayerEvent);
_player.addEventListener(PlayerEvents.VOLUME_UP, onPlayerEvent);
_player.addEventListener(PlayerEvents.VOLUME_DOWN, onPlayerEvent);
_player.addEventListener(PlayerEvents.VOLUME_CHANGE, onPlayerEvent);
_player.addEventListener(PlayerEvents.MUTE, onPlayerEvent);
_player.addEventListener(PlayerEvents.TIME, onPlayerEvent);
_player.addEventListener(PlayerEvents.PROGRESS, onPlayerEvent);
_player.addEventListener(PlayerEvents.SEEK, onPlayerEvent);
ExternalInterface.addCallback("api_get", getAttribute);
ExternalInterface.addCallback("api_addlistener", addJsListener);
ExternalInterface.addCallback("api_removelistener", removeJsListener);
ExternalInterface.addCallback("api_play", setPlay);
ExternalInterface.addCallback("api_pause", setPause);
ExternalInterface.addCallback("api_seek", setSeek);
ExternalInterface.addCallback("api_volume", setVolume);
ExternalInterface.addCallback("api_loadVideo", loadVideo);
}
public function getAttribute(attribute:String):Float {
switch (attribute) {
case 'isBuffering':
return (_isBuffering) ? 1 : 0;
case 'isPlaying':
return (_player.isPlaying()) ? 1 : 0;
case 'time':
return Math.round(_player.getCurrentTime() * 10) / 10;
case 'loaded':
return _player.getBytesLoaded();
case 'volume':
return (_player.getMute()==true) ? 0 : _player.getVolume();
}
return 0;
}
public function addJsListener(attribute:String, parameter:String):Void {
_externalListeners.set(attribute.toLowerCase(), parameter);
}
public function removeJsListener(attribute:String):Void {
if (attribute == '*')
{
_externalListeners = new Map();
return;
}
_externalListeners.remove(attribute.toLowerCase());
}
public function onPlayerEvent(event:PlayerEvents):Void
{
var jsFunction = '';
var data = {
duration: event.duration,
fullscreen: event.fullscreen,
mute: event.mute,
volume: event.volume,
position: event.time,
type: event.name,
loaded: _player.getBytesLoaded(),
total: _player.getBytesTotal()
};
if (_externalListeners.exists(event.name.toLowerCase()))
{
ExternalInterface.call(_externalListeners.get(event.name.toLowerCase()), data);
}
if (_externalListeners.exists('on*'))
{
ExternalInterface.call(_externalListeners.get('on*'), data);
}
}
/**
* Toggles pause or play
*/
private function setPlay():Void
{
if (_player.isPlaying()!=true) {
_player.togglePlay();
}
}
/**
* Toggles play or pause
*/
private function setPause():Void
{
if (_player.isPlaying()==true) {
_player.togglePlay();
}
}
/**
* Set Seek
*/
private function setSeek(pos:Float):Void
{
_player.seek(pos);
}
/**
* Set Volume
*/
private function setVolume(vol:Float):Void
{
if (vol <= 0 && _player.getMute()!=true) {
_player.toggleMute();
_player.setVolume(0);
return;
}
if (_player.getMute() == true) {
_player.toggleMute();
}
if (vol >= 1) {
_player.setVolume(1);
return;
}
_player.setVolume(vol);
}
/**
* Loads another video
*/
private function loadVideo(source:String, type:String="video", streamType:String="file", server:String=""):Void
{
if (_player.isPlaying()==true) {
_player.togglePlay();
}
_player.load(source, type, streamType, server);
}
}
v2.0.17~dfsg/src/jaris/player/controls/ 0000755 0000000 0000000 00000000000 12625374554 016604 5 ustar root root v2.0.17~dfsg/src/jaris/player/controls/AspectRatioIcon.hx 0000644 0000000 0000000 00000006152 12625374554 022200 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.controls;
import flash.display.Sprite;
import flash.events.MouseEvent;
class AspectRatioIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(2, color);
graphics.drawRect(0, 0, _width, _height);
var innerWidth:Float = (60 / 100) * width;
var innerHeight:Float = (60 / 100) * height;
var innerX:Float = (width / 2) - (innerWidth / 2) - 1;
var innerY:Float = (height / 2) - (innerHeight / 2) - 1;
graphics.lineStyle();
graphics.beginFill(color, 1);
graphics.drawRect(innerX, innerY, innerWidth, innerHeight);
graphics.endFill();
graphics.lineStyle();
graphics.beginFill(0, 0);
graphics.drawRect(0, 0, width, height);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/controls/PauseIcon.hx 0000644 0000000 0000000 00000005622 12625374554 021040 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.controls;
import flash.display.Sprite;
import flash.events.MouseEvent;
class PauseIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle();
graphics.beginFill(color);
graphics.drawRoundRect(0, 0, (33 / 100) * _width, _height, 6, 6);
graphics.drawRoundRect(_width - ((33 / 100) * _width), 0, (33 / 100) * _width, _height, 6, 6);
graphics.endFill();
graphics.lineStyle();
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/controls/VolumeIcon.hx 0000644 0000000 0000000 00000005631 12625374554 021232 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.controls;
import flash.display.Sprite;
import flash.events.MouseEvent;
class VolumeIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle();
graphics.beginFill(color, 1);
graphics.drawRect(0, ((50 / 100) * _height) / 2, _width / 2, ((50 / 100) * _height));
graphics.moveTo(_width / 2, ((50 / 100) * _height)/2);
graphics.lineTo(_width, 0);
graphics.lineTo(_width, _height);
graphics.lineTo(_width / 2, ((50 / 100) * _height) + (((50 / 100) * _height) / 2));
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/controls/Controls.hx 0000644 0000000 0000000 00000073635 12625374554 020766 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.controls;
//{Libraries
import flash.display.GradientType;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.Matrix;
import flash.Lib;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.net.NetStream;
import flash.geom.Rectangle;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.utils.Timer;
import jaris.animation.Animation;
import jaris.display.Loader;
import jaris.events.PlayerEvents;
import jaris.player.controls.AspectRatioIcon;
import jaris.player.controls.FullscreenIcon;
import jaris.player.controls.PauseIcon;
import jaris.player.controls.PlayIcon;
import jaris.player.controls.VolumeIcon;
import jaris.player.Player;
import flash.display.Sprite;
import flash.display.Stage;
import jaris.utils.Utils;
//}
/**
* Default controls for jaris player
*/
class Controls extends MovieClip {
//{Member Variables
private var _thumb:Sprite;
private var _track:Sprite;
private var _trackDownloaded:Sprite;
private var _scrubbing:Bool;
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _player:Player;
private var _darkColor:UInt;
private var _brightColor:UInt;
private var _controlColor:UInt;
private var _hoverColor:UInt;
private var _hideControlsTimer:Timer;
private var _hideAspectRatioLabelTimer:Timer;
private var _currentPlayTimeLabel:TextField;
private var _totalPlayTimeLabel:TextField;
private var _seekPlayTimeLabel:TextField;
private var _percentLoaded:Float;
private var _controlsVisible:Bool;
private var _seekBar:Sprite;
private var _controlsBar:Sprite;
private var _playControl:PlayIcon;
private var _pauseControl:PauseIcon;
private var _aspectRatioControl:AspectRatioIcon;
private var _fullscreenControl:FullscreenIcon;
private var _volumeIcon:VolumeIcon;
private var _volumeTrack:Sprite;
private var _volumeSlider:Sprite;
private var _loader:Loader;
private var _aspectRatioLabelContainer:Sprite;
private var _aspectRatioLabel:TextField;
private var _textFormat:TextFormat;
//}
//{Constructor
public function new(player:Player)
{
super();
//{Main variables
_stage = Lib.current.stage;
_movieClip = Lib.current;
_player = player;
_darkColor = 0x000000;
_brightColor = 0x4c4c4c;
_controlColor = 0xFFFFFF;
_hoverColor = 0x67A8C1;
_percentLoaded = 0.0;
_hideControlsTimer = new Timer(500);
_hideAspectRatioLabelTimer = new Timer(500);
_controlsVisible = false;
_textFormat = new TextFormat();
_textFormat.font = "arial";
_textFormat.color = _controlColor;
_textFormat.size = 14;
//}
//{Seeking Controls initialization
_seekBar = new Sprite();
addChild(_seekBar);
_trackDownloaded = new Sprite( );
_trackDownloaded.tabEnabled = false;
_seekBar.addChild(_trackDownloaded);
_track = new Sprite( );
_track.tabEnabled = false;
_track.buttonMode = true;
_track.useHandCursor = true;
_seekBar.addChild(_track);
_thumb = new Sprite( );
_thumb.buttonMode = true;
_thumb.useHandCursor = true;
_thumb.tabEnabled = false;
_seekBar.addChild(_thumb);
_currentPlayTimeLabel = new TextField();
_currentPlayTimeLabel.autoSize = TextFieldAutoSize.LEFT;
_currentPlayTimeLabel.text = "00:00:00";
_currentPlayTimeLabel.tabEnabled = false;
_currentPlayTimeLabel.setTextFormat(_textFormat);
_seekBar.addChild(_currentPlayTimeLabel);
_totalPlayTimeLabel = new TextField();
_totalPlayTimeLabel.autoSize = TextFieldAutoSize.LEFT;
_totalPlayTimeLabel.text = "00:00:00";
_totalPlayTimeLabel.tabEnabled = false;
_totalPlayTimeLabel.setTextFormat(_textFormat);
_seekBar.addChild(_totalPlayTimeLabel);
_seekPlayTimeLabel = new TextField();
_seekPlayTimeLabel.visible = false;
_seekPlayTimeLabel.autoSize = TextFieldAutoSize.LEFT;
_seekPlayTimeLabel.text = "00:00:00";
_seekPlayTimeLabel.tabEnabled = false;
_seekPlayTimeLabel.setTextFormat(_textFormat);
addChild(_seekPlayTimeLabel);
//}
//{Playing controls initialization
_controlsBar = new Sprite();
_controlsBar.visible = true;
addChild(_controlsBar);
_playControl = new PlayIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_playControl);
_pauseControl = new PauseIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_pauseControl.visible = false;
_controlsBar.addChild(_pauseControl);
_aspectRatioControl = new AspectRatioIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_aspectRatioControl);
_fullscreenControl = new FullscreenIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_fullscreenControl);
_volumeIcon = new VolumeIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_volumeIcon);
_volumeSlider = new Sprite();
_controlsBar.addChild(_volumeSlider);
_volumeTrack = new Sprite();
_volumeTrack.buttonMode = true;
_volumeTrack.useHandCursor = true;
_volumeTrack.tabEnabled = false;
_controlsBar.addChild(_volumeTrack);
//}
//{Aspect ratio label
_aspectRatioLabelContainer = new Sprite();
addChild(_aspectRatioLabelContainer);
_aspectRatioLabel = new TextField();
_aspectRatioLabel.autoSize = TextFieldAutoSize.CENTER;
_aspectRatioLabel.text = "original";
_aspectRatioLabel.tabEnabled = false;
_aspectRatioLabelContainer.addChild(_aspectRatioLabel);
//}
redrawControls();
//{Loader bar
_loader = new Loader();
_loader.hide();
var loaderColors:Array = ["", "", "", ""];
loaderColors[0] = Std.string(_brightColor);
loaderColors[1] = Std.string(_controlColor);
_loader.setColors(loaderColors);
addChild(_loader);
//}
//{event Listeners
_movieClip.addEventListener(Event.ENTER_FRAME, onEnterFrame);
_thumb.addEventListener(MouseEvent.MOUSE_DOWN, onThumbMouseDown);
_thumb.addEventListener(MouseEvent.MOUSE_UP, onThumbMouseUp);
_thumb.addEventListener(MouseEvent.MOUSE_OVER, onThumbHover);
_thumb.addEventListener(MouseEvent.MOUSE_OUT, onThumbMouseOut);
_thumb.addEventListener(MouseEvent.MOUSE_MOVE, onTrackMouseMove);
_thumb.addEventListener(MouseEvent.MOUSE_OUT, onTrackMouseOut);
_track.addEventListener(MouseEvent.CLICK, onTrackClick);
_track.addEventListener(MouseEvent.MOUSE_MOVE, onTrackMouseMove);
_track.addEventListener(MouseEvent.MOUSE_OUT, onTrackMouseOut);
_playControl.addEventListener(MouseEvent.CLICK, onPlayClick);
_pauseControl.addEventListener(MouseEvent.CLICK, onPauseClick);
_aspectRatioControl.addEventListener(MouseEvent.CLICK, onAspectRatioClick);
_fullscreenControl.addEventListener(MouseEvent.CLICK, onFullscreenClick);
_volumeIcon.addEventListener(MouseEvent.CLICK, onVolumeIconClick);
_volumeTrack.addEventListener(MouseEvent.CLICK, onVolumeTrackClick);
_player.addEventListener(PlayerEvents.MOUSE_HIDE, onPlayerMouseHide);
_player.addEventListener(PlayerEvents.MOUSE_SHOW, onPlayerMouseShow);
_player.addEventListener(PlayerEvents.MEDIA_INITIALIZED, onPlayerMediaInitialized);
_player.addEventListener(PlayerEvents.BUFFERING, onPlayerBuffering);
_player.addEventListener(PlayerEvents.NOT_BUFFERING, onPlayerNotBuffering);
_player.addEventListener(PlayerEvents.RESIZE, onPlayerResize);
_player.addEventListener(PlayerEvents.PLAY_PAUSE, onPlayerPlayPause);
_player.addEventListener(PlayerEvents.PLAYBACK_FINISHED, onPlayerPlaybackFinished);
_player.addEventListener(PlayerEvents.CONNECTION_FAILED, onPlayerStreamNotFound);
_player.addEventListener(PlayerEvents.ASPECT_RATIO, onPlayerAspectRatio);
_stage.addEventListener(MouseEvent.MOUSE_UP, onThumbMouseUp);
_stage.addEventListener(MouseEvent.MOUSE_OUT, onThumbMouseUp);
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
_stage.addEventListener(Event.RESIZE, onStageResize);
_hideControlsTimer.addEventListener(TimerEvent.TIMER, hideControlsTimer);
_hideAspectRatioLabelTimer.addEventListener(TimerEvent.TIMER, hideAspectRatioLabelTimer);
_hideControlsTimer.start();
//}
}
//}
//{Timers
/**
* Hides the playing controls when not moving mouse.
* @param event The timer event associated
*/
private function hideControlsTimer(event:TimerEvent):Void
{
if (_player.isPlaying())
{
if (_controlsVisible)
{
if (_stage.mouseX < _controlsBar.x ||
_stage.mouseX >= _stage.stageWidth - 1 ||
_stage.mouseY >= _stage.stageHeight - 1 ||
_stage.mouseY <= 1
)
{
_controlsVisible = false;
}
}
else
{
hideControls();
_hideControlsTimer.stop();
}
}
}
/**
* Hides aspect ratio label
* @param event
*/
private function hideAspectRatioLabelTimer(event:TimerEvent):Void
{
//wait till fade in effect finish
if (_aspectRatioLabelContainer.alpha >= 1)
{
Animation.fadeOut(_aspectRatioLabelContainer, 300);
_hideAspectRatioLabelTimer.stop();
}
}
//}
//{Events
/**
* Keeps syncronized various elements of the controls like the thumb and download track bar
* @param event
*/
private function onEnterFrame(event:Event):Void
{
if(_player.getDuration() > 0) {
if (_scrubbing)
{
_player.seek(((_thumb.x - _track.x) / _track.width) * _player.getDuration());
}
else
{
_currentPlayTimeLabel.text = Utils.formatTime(_player.getCurrentTime());
_currentPlayTimeLabel.setTextFormat(_textFormat);
_thumb.x = _player.getCurrentTime() / _player.getDuration() * (_track.width-_thumb.width) + _track.x;
}
}
_volumeSlider.height = _volumeTrack.height * (_player.getVolume() / 1.0);
_volumeSlider.y = (_volumeTrack.y + _volumeTrack.height) - _volumeSlider.height;
drawDownloadProgress();
}
/**
* Show playing controls on mouse movement.
* @param event
*/
private function onMouseMove(event:MouseEvent):Void
{
if (_stage.mouseX >= _controlsBar.x)
{
if (!_hideControlsTimer.running)
{
_hideControlsTimer.start();
}
_controlsVisible = true;
showControls();
}
}
/**
* Function fired by a stage resize eventthat redraws the player controls
* @param event
*/
private function onStageResize(event:Event):Void
{
redrawControls();
}
/**
* Toggles pause or play
* @param event
*/
private function onPlayClick(event:MouseEvent):Void
{
_player.togglePlay();
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Toggles pause or play
* @param event
*/
private function onPauseClick(event:MouseEvent):Void
{
_player.togglePlay();
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Toggles betewen aspect ratios
* @param event
*/
private function onAspectRatioClick(event:MouseEvent):Void
{
_player.toggleAspectRatio();
}
/**
* Toggles between window and fullscreen mode
* @param event
*/
private function onFullscreenClick(event:MouseEvent):Void
{
_player.toggleFullscreen();
}
/**
* Toggles between mute and unmute
* @param event
*/
private function onVolumeIconClick(event: MouseEvent):Void
{
_player.toggleMute();
}
/**
* Detect user click on volume track control and change volume according
* @param event
*/
private function onVolumeTrackClick(event:MouseEvent):Void
{
var percent:Float = _volumeTrack.height - _volumeTrack.mouseY;
var volume:Float = 1.0 * (percent / _volumeTrack.height);
_player.setVolume(volume);
}
/**
* Display not found message
* @param event
*/
private function onPlayerStreamNotFound(event:PlayerEvents):Void
{
//todo: to work on this
}
/**
* Shows the loader bar when buffering
* @param event
*/
private function onPlayerBuffering(event:PlayerEvents):Void
{
_loader.show();
}
/**
* Hides loader bar when not buffering
* @param event
*/
private function onPlayerNotBuffering(event:PlayerEvents):Void
{
_loader.hide();
}
/**
* Show the selected aspect ratio
* @param event
*/
private function onPlayerAspectRatio(event:PlayerEvents):Void
{
_hideAspectRatioLabelTimer.stop();
_aspectRatioLabel.text = _player.getAspectRatioString();
drawAspectRatioLabel();
while (_aspectRatioLabelContainer.visible)
{
//wait till fade out finishes
}
Animation.fadeIn(_aspectRatioLabelContainer, 300);
_hideAspectRatioLabelTimer.start();
}
/**
* Monitors playbeack when finishes tu update controls
* @param event
*/
private function onPlayerPlaybackFinished(event:PlayerEvents):Void
{
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
showControls();
}
/**
* Monitors keyboard play pause actions to update icons
* @param event
*/
private function onPlayerPlayPause(event:PlayerEvents):Void
{
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Resizes the video player on windowed mode substracting the seekbar height
* @param event
*/
private function onPlayerResize(event:PlayerEvents):Void
{
if (!_player.isFullscreen())
{
if (_player.getVideo().y + _player.getVideo().height >= _stage.stageHeight)
{
_player.getVideo().height = _stage.stageHeight - _seekBar.height;
_player.getVideo().width = _player.getVideo().height * _player.getAspectRatio();
_player.getVideo().x = (_stage.stageWidth / 2) - (_player.getVideo().width / 2);
}
}
}
/**
* Updates media total time duration.
* @param event
*/
private function onPlayerMediaInitialized(event:PlayerEvents):Void
{
_totalPlayTimeLabel.text = Utils.formatTime(event.duration);
_totalPlayTimeLabel.setTextFormat(_textFormat);
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Hides seekbar if on fullscreen.
* @param event
*/
private function onPlayerMouseHide(event:PlayerEvents):Void
{
if (_seekBar.visible && _player.isFullscreen())
{
Animation.slideOut(_seekBar, "bottom", 1000);
}
}
/**
* Shows seekbar
* @param event
*/
private function onPlayerMouseShow(event:PlayerEvents):Void
{
//Only use slidein effect on fullscreen since switching to windowed mode on
//hardware scaling causes a bug by a slow response on stage height changes
if (_player.isFullscreen() && !_seekBar.visible)
{
Animation.slideIn(_seekBar, "bottom",1000);
}
else
{
_seekBar.visible = true;
}
}
/**
* Translates a user click in to time and seeks to it
* @param event
*/
private function onTrackClick(event:MouseEvent):Void
{
var clickPosition:Float = _track.mouseX;
_player.seek(_player.getDuration() * (clickPosition / _track.width));
}
/**
* Shows a small tooltip showing the time calculated by mouse position
* @param event
*/
private function onTrackMouseMove(event:MouseEvent):Void
{
var clickPosition:Float = _track.mouseX;
_seekPlayTimeLabel.text = Utils.formatTime(_player.getDuration() * (clickPosition / _track.width));
_seekPlayTimeLabel.setTextFormat(_textFormat);
_seekPlayTimeLabel.y = _stage.stageHeight - _seekBar.height - _seekPlayTimeLabel.height - 1;
_seekPlayTimeLabel.x = clickPosition + (_seekPlayTimeLabel.width / 2);
_seekPlayTimeLabel.backgroundColor = _brightColor;
_seekPlayTimeLabel.background = true;
_seekPlayTimeLabel.textColor = _controlColor;
_seekPlayTimeLabel.borderColor = _darkColor;
_seekPlayTimeLabel.border = true;
if (!_seekPlayTimeLabel.visible)
{
Animation.fadeIn(_seekPlayTimeLabel, 300);
}
}
/**
* Hides the tooltip that shows the time calculated by mouse position
* @param event
*/
private function onTrackMouseOut(event:MouseEvent):Void
{
Animation.fadeOut(_seekPlayTimeLabel, 300);
}
/**
* Enables dragging of thumb for seeking media
* @param event
*/
private function onThumbMouseDown(event:MouseEvent):Void
{
_scrubbing = true;
var rectangle:Rectangle = new Rectangle(_track.x, _track.y, _track.width-_thumb.width, 0);
_thumb.startDrag(false, rectangle);
}
/**
* Changes thumb seek control to hover color
* @param event
*/
private function onThumbHover(event:MouseEvent):Void
{
_thumb.graphics.lineStyle();
_thumb.graphics.beginFill(_hoverColor);
_thumb.graphics.drawRect(0, (_seekBar.height/2)-(10/2), 10, 10);
_thumb.graphics.endFill();
}
/**
* Changes thumb seek control to control color
* @param event
*/
private function onThumbMouseOut(event:MouseEvent):Void
{
_thumb.graphics.lineStyle();
_thumb.graphics.beginFill(_controlColor);
_thumb.graphics.drawRect(0, (_seekBar.height/2)-(10/2), 10, 10);
_thumb.graphics.endFill();
}
/**
* Disables dragging of thumb
* @param event
*/
private function onThumbMouseUp(event:MouseEvent):Void
{
_scrubbing = false;
_thumb.stopDrag( );
}
//}
//{Drawing functions
/**
* Clears all current graphics a draw new ones
*/
private function redrawControls():Void
{
drawSeekControls();
drawPlayingControls();
drawAspectRatioLabel();
}
/**
* Draws the download progress track bar
*/
private function drawDownloadProgress():Void
{
if (_player.getBytesTotal() > 0)
{
var bytesLoaded:Float = _player.getBytesLoaded();
var bytesTotal:Float = _player.getBytesTotal();
_percentLoaded = bytesLoaded / bytesTotal;
}
var position:Float = _player.getStartTime() / _player.getDuration();
//var startPosition:Float = (position * _track.width) + _track.x; //Old way
var startPosition:Float = (position > 0?(position * _track.width):0) + _track.x;
_trackDownloaded.graphics.clear();
_trackDownloaded.graphics.lineStyle();
_trackDownloaded.x = startPosition;
_trackDownloaded.graphics.beginFill(_brightColor, 0xFFFFFF);
_trackDownloaded.graphics.drawRect(0, (_seekBar.height / 2) - (10 / 2), ((_track.width + _track.x) - _trackDownloaded.x) * _percentLoaded, 10);
_trackDownloaded.graphics.endFill();
}
/**
* Draws all seekbar controls
*/
private function drawSeekControls()
{
//Reset sprites for redraw
_seekBar.graphics.clear();
_track.graphics.clear();
_thumb.graphics.clear();
//Draw seek bar
var _seekBarWidth:UInt = _stage.stageWidth;
var _seekBarHeight:UInt = 25;
_seekBar.x = 0;
_seekBar.y = _stage.stageHeight - _seekBarHeight;
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_seekBarWidth, _seekBarHeight, Utils.degreesToRadians(90), 0, 0);
var colors:Array = [_brightColor, _darkColor];
var alphas:Array = [1, 1];
var ratios:Array = [0, 255];
_seekBar.graphics.lineStyle();
_seekBar.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
_seekBar.graphics.drawRect(0, 0, _seekBarWidth, _seekBarHeight);
_seekBar.graphics.endFill();
_textFormat.color = _controlColor;
//Draw current play time label
_currentPlayTimeLabel.y = _seekBarHeight - (_seekBarHeight / 2) - (_currentPlayTimeLabel.height / 2);
_currentPlayTimeLabel.antiAliasType = AntiAliasType.ADVANCED;
_currentPlayTimeLabel.setTextFormat(_textFormat);
//Draw total play time label
_totalPlayTimeLabel.x = _seekBarWidth - _totalPlayTimeLabel.width;
_totalPlayTimeLabel.y = _seekBarHeight - (_seekBarHeight / 2) - (_totalPlayTimeLabel.height / 2);
_totalPlayTimeLabel.antiAliasType = AntiAliasType.ADVANCED;
_totalPlayTimeLabel.setTextFormat(_textFormat);
//Draw download progress
drawDownloadProgress();
//Draw track place holder for drag
_track.x = _currentPlayTimeLabel.width;
_track.graphics.lineStyle(1, _controlColor);
_track.graphics.beginFill(_darkColor, 0);
_track.graphics.drawRect(0, (_seekBarHeight / 2) - (10 / 2), _seekBarWidth - _currentPlayTimeLabel.width - _totalPlayTimeLabel.width, 10);
_track.graphics.endFill();
//Draw thumb
_thumb.x = _currentPlayTimeLabel.width;
_thumb.graphics.lineStyle();
_thumb.graphics.beginFill(_controlColor);
_thumb.graphics.drawRect(0, (_seekBarHeight/2)-(10/2), 10, 10);
_thumb.graphics.endFill();
}
/**
* Draws control bar player controls
*/
private function drawPlayingControls():Void
{
//Reset sprites for redraw
_controlsBar.graphics.clear();
_volumeTrack.graphics.clear();
_volumeSlider.graphics.clear();
//Draw controls bar
var barMargin = _stage.stageHeight < 330 ? 5 : 25;
var barHeight = _stage.stageHeight - _seekBar.height - (barMargin * 2);
var barWidth = _stage.stageHeight < 330 ? 45 : 60;
_controlsBar.x = (_stage.stageWidth - barWidth) + 20;
_controlsBar.y = barMargin;
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(barWidth, barHeight, Utils.degreesToRadians(0), 0, barHeight);
var colors:Array = [_brightColor, _darkColor];
var alphas:Array = [0.75, 0.75];
var ratios:Array = [0, 255];
_controlsBar.graphics.lineStyle();
_controlsBar.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
_controlsBar.graphics.drawRoundRect(0, 0, barWidth, barHeight, 20, 20);
_controlsBar.graphics.endFill();
var topMargin:Float = _stage.stageHeight < 330 ? 5 : 10;
var barCenter:Float = (barWidth - 20) / 2;
var buttonSize:Float = ((80 / 100) * (barWidth - 20));
var buttonX:Float = buttonSize / 2;
//Draw playbutton
_playControl.setNormalColor(_controlColor);
_playControl.setHoverColor(_hoverColor);
_playControl.setPosition(barCenter - buttonX, topMargin);
_playControl.setSize(buttonSize, buttonSize);
//Draw pausebutton
_pauseControl.setNormalColor(_controlColor);
_pauseControl.setHoverColor(_hoverColor);
_pauseControl.setPosition(_playControl.x, topMargin);
_pauseControl.setSize(buttonSize, buttonSize);
//Draw aspec ratio button
_aspectRatioControl.setNormalColor(_controlColor);
_aspectRatioControl.setHoverColor(_hoverColor);
_aspectRatioControl.setPosition(_playControl.x, (_playControl.y + buttonSize) + topMargin);
_aspectRatioControl.setSize(buttonSize, buttonSize);
//Draw fullscreen button
_fullscreenControl.setNormalColor(_controlColor);
_fullscreenControl.setHoverColor(_hoverColor);
_fullscreenControl.setPosition(_playControl.x, (_aspectRatioControl.y + _aspectRatioControl.height) + topMargin);
_fullscreenControl.setSize(buttonSize, buttonSize);
//Draw volume icon
_volumeIcon.setNormalColor(_controlColor);
_volumeIcon.setHoverColor(_hoverColor);
_volumeIcon.setPosition(_playControl.x, barHeight - _playControl.height - topMargin);
_volumeIcon.setSize(buttonSize, buttonSize);
//Draw volume track
_volumeTrack.x = _playControl.x;
_volumeTrack.y = (_fullscreenControl.y + _fullscreenControl.height) + topMargin;
_volumeTrack.graphics.lineStyle(1, _controlColor);
_volumeTrack.graphics.beginFill(0x000000, 0);
_volumeTrack.graphics.drawRect(0, 0, _playControl.width / 2, _volumeIcon.y - (_fullscreenControl.y + _fullscreenControl.height) - (topMargin*2));
_volumeTrack.graphics.endFill();
_volumeTrack.x = barCenter - (_volumeTrack.width / 2);
//Draw volume slider
_volumeSlider.x = _volumeTrack.x;
_volumeSlider.y = _volumeTrack.y;
_volumeSlider.graphics.lineStyle();
_volumeSlider.graphics.beginFill(_controlColor, 1);
_volumeSlider.graphics.drawRect(0, 0, _volumeTrack.width, _volumeTrack.height);
_volumeSlider.graphics.endFill();
}
private function drawAspectRatioLabel():Void
{
_aspectRatioLabelContainer.graphics.clear();
_aspectRatioLabelContainer.visible = false;
//Update aspect ratio label
var textFormat:TextFormat = new TextFormat();
textFormat.font = "arial";
textFormat.bold = true;
textFormat.size = 40;
textFormat.color = _controlColor;
_aspectRatioLabel.setTextFormat(textFormat);
_aspectRatioLabel.x = (_stage.stageWidth / 2) - (_aspectRatioLabel.width / 2);
_aspectRatioLabel.y = (_stage.stageHeight / 2) - (_aspectRatioLabel.height / 2);
//Draw aspect ratio label container
_aspectRatioLabelContainer.x = _aspectRatioLabel.x - 10;
_aspectRatioLabelContainer.y = _aspectRatioLabel.y - 10;
_aspectRatioLabelContainer.graphics.lineStyle(3, _controlColor);
_aspectRatioLabelContainer.graphics.beginFill(_brightColor, 1);
_aspectRatioLabelContainer.graphics.drawRoundRect(0, 0, _aspectRatioLabel.width + 20, _aspectRatioLabel.height + 20, 15, 15);
_aspectRatioLabelContainer.graphics.endFill();
_aspectRatioLabel.x = 10;
_aspectRatioLabel.y = 10;
}
//}
//{Private Methods
/**
* Hide the play controls bar
*/
private function hideControls():Void
{
if(_controlsBar.visible)
{
drawPlayingControls();
Animation.slideOut(_controlsBar, "right", 800);
}
}
/**
* Shows play controls bar
*/
private function showControls():Void
{
if(!_controlsBar.visible)
{
drawPlayingControls();
Animation.slideIn(_controlsBar, "right", 800);
}
}
//}
//{Setters
/**
* Sets the player colors and redraw them
* @param colors Array of colors in the following order: darkColor, brightColor, controlColor, hoverColor
*/
public function setControlColors(colors:Array):Void
{
_darkColor = colors[0].length > 0? Std.parseInt("0x" + colors[0]) : 0x000000;
_brightColor = colors[1].length > 0? Std.parseInt("0x" + colors[1]) : 0x4c4c4c;
_controlColor = colors[2].length > 0? Std.parseInt("0x" + colors[2]) : 0xFFFFFF;
_hoverColor = colors[3].length > 0? Std.parseInt("0x" + colors[3]) : 0x67A8C1;
var loaderColors:Array = ["", ""];
loaderColors[0] = colors[1];
loaderColors[1] = colors[2];
_loader.setColors(loaderColors);
redrawControls();
}
/**
* To set the duration label when autostart parameter is false
* @param duration in seconds or formatted string in format hh:mm:ss
*/
public function setDurationLabel(duration:String):Void
{
//Person passed time already formatted
if (duration.indexOf(":") != -1)
{
_totalPlayTimeLabel.text = duration;
}
//Time passed in seconds
else
{
_totalPlayTimeLabel.text = Std.string(Utils.formatTime(Std.parseFloat(duration)));
}
_totalPlayTimeLabel.setTextFormat(_textFormat);
}
//}
}
v2.0.17~dfsg/src/jaris/player/controls/FullscreenIcon.hx 0000644 0000000 0000000 00000005751 12625374554 022070 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.controls;
import flash.display.Sprite;
import flash.events.MouseEvent;
class FullscreenIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(2, color);
graphics.beginFill(0x000000, 0);
graphics.drawRoundRect(0, 0, _width, _height, 6, 6);
graphics.endFill();
graphics.lineStyle();
graphics.beginFill(color, 1);
graphics.drawRoundRect(3, 3, 4, 4, 2, 2);
graphics.drawRoundRect(width - 9, 3, 4, 4, 2, 2);
graphics.drawRoundRect(3, height - 9, 4, 4, 2, 2);
graphics.drawRoundRect(width - 9, height - 9, 4, 4, 2, 2);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/controls/PlayIcon.hx 0000644 0000000 0000000 00000005276 12625374554 020675 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.controls;
import flash.display.Sprite;
import flash.events.MouseEvent;
class PlayIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle();
graphics.beginFill(color);
graphics.lineTo(0, _height);
graphics.lineTo(_width, _height / 2);
graphics.lineTo(0, 0);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/Loop.hx 0000755 0000000 0000000 00000002604 12625374554 016220 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
//{Libraries
import jaris.events.PlayerEvents;
//}
/**
* Implements a loop mechanism on the player
*/
class Loop
{
private var _player:Player;
public function new(player:Player)
{
_player = player;
_player.addEventListener(PlayerEvents.PLAYBACK_FINISHED, onPlayerStop);
}
/**
* Everytime the player stops, the playback is restarted
* @param event
*/
private function onPlayerStop(event:PlayerEvents):Void
{
_player.togglePlay();
}
}
v2.0.17~dfsg/src/jaris/player/StreamType.hx 0000644 0000000 0000000 00000002200 12625374554 017371 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
/**
* Some constants for the stream types
*/
class StreamType
{
public static var FILE:String = "file";
public static var PSEUDOSTREAM:String = "http";
public static var RTMP:String = "rtmp";
public static var YOUTUBE = "youtube";
}
v2.0.17~dfsg/src/jaris/player/newcontrols/ 0000755 0000000 0000000 00000000000 12625374554 017316 5 ustar root root v2.0.17~dfsg/src/jaris/player/newcontrols/AspectRatioIcon.hx 0000755 0000000 0000000 00000007264 12625374554 022722 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import jaris.utils.Utils;
import flash.display.GradientType;
class AspectRatioIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(0, color, 0.0);
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_width, _height, Utils.degreesToRadians(-90), _width, 0);
var colors:Array = [color, color];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
var innerWidth:Float = (70 / 100) * width;
var innerHeight:Float = (40 / 100) * height;
var innerX:Float = (width / 2) - (innerWidth / 2) + 1 ;
var innerY:Float = (height / 2) - (innerHeight / 2) + 1;
graphics.lineStyle();
graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//graphics.beginFill(color, 1);
graphics.drawRect(0, 0, 1, _height+1);
graphics.drawRect(0, 0, _width+1, 1);
graphics.drawRect(_width+1, 0, 1, _height+1);
graphics.drawRect(0, _height+1, _width+1, 1);
graphics.drawRect(innerX, innerY, innerWidth, innerHeight);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/newcontrols/PauseIcon.hx 0000755 0000000 0000000 00000006770 12625374554 021562 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import jaris.utils.Utils;
import flash.display.GradientType;
class PauseIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(0, color, 0.0);
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_width, _height, Utils.degreesToRadians(-90), _width, 0);
var colors:Array = [color, color];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
graphics.lineStyle();
graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//graphics.beginFill(color);
graphics.drawRoundRect(0, 0, (33 / 100) * _width, _height, 6, 6);
graphics.drawRoundRect(_width - ((33 / 100) * _width), 0, (33 / 100) * _width, _height, 6, 6);
graphics.endFill();
graphics.lineStyle();
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/newcontrols/VolumeIcon.hx 0000755 0000000 0000000 00000007017 12625374554 021747 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import jaris.utils.Utils;
import flash.display.GradientType;
class VolumeIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(0, color, 0.0);
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_width, _height, Utils.degreesToRadians(-90), _width, 0);
var colors:Array = [color, color];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
graphics.lineStyle();
graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//graphics.beginFill(color, 1);
graphics.drawRect(0, ((50 / 100) * _height) / 2+1, _width / 2-1, ((50 / 100) * _height));
graphics.moveTo(_width / 2 -1, ((50 / 100) * _height)/2+1);
graphics.lineTo(_width, 0);
graphics.lineTo(_width, _height+2);
graphics.lineTo(_width / 2 -1, ((50 / 100) * _height) + (((50 / 100) * _height) / 2)+1);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/newcontrols/NewControls.hx 0000755 0000000 0000000 00000076606 12625374554 022156 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
//{Libraries
import flash.display.GradientType;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.Matrix;
import flash.Lib;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.net.NetStream;
import flash.geom.Rectangle;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.utils.Timer;
import jaris.animation.Animation;
import jaris.events.PlayerEvents;
import jaris.player.newcontrols.Loader;
import jaris.player.newcontrols.AspectRatioIcon;
import jaris.player.newcontrols.FullscreenIcon;
import jaris.player.newcontrols.PauseIcon;
import jaris.player.newcontrols.PlayIcon;
import jaris.player.newcontrols.VolumeIcon;
import jaris.player.Player;
import flash.display.Sprite;
import flash.display.Stage;
import jaris.utils.Utils;
//}
/**
* Default controls for jaris player
*/
class NewControls extends MovieClip {
//{Member Variables
private var _thumb:Sprite;
private var _track:Sprite;
private var _trackDownloaded:Sprite;
private var _scrubbing:Bool;
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _player:Player;
private var _darkColor:UInt;
private var _brightColor:UInt;
private var _seekColor:UInt;
private var _controlColor:UInt;
private var _controlSize:Int;
private var _hoverColor:UInt;
private var _hideControlsTimer:Timer;
private var _hideAspectRatioLabelTimer:Timer;
private var _currentPlayTimeLabel:TextField;
private var _totalPlayTimeLabel:TextField;
private var _seekPlayTimeLabel:TextField;
private var _percentLoaded:Float;
private var _controlsVisible:Bool;
private var _seekBar:Sprite;
private var _controlsBar:Sprite;
private var _playControl:PlayIcon;
private var _pauseControl:PauseIcon;
private var _aspectRatioControl:AspectRatioIcon;
private var _fullscreenControl:FullscreenIcon;
private var _volumeIcon:VolumeIcon;
private var _volumeTrack:Sprite;
private var _volumeSlider:Sprite;
private var _loader:Loader;
private var _aspectRatioLabelContainer:Sprite;
private var _aspectRatioLabel:TextField;
private var _textFormat:TextFormat;
//}
//{Constructor
public function new(player:Player)
{
super();
//{Main variables
_stage = Lib.current.stage;
_movieClip = Lib.current;
_player = player;
_darkColor = 0x000000;
_brightColor = 0x4c4c4c;
_controlColor = 0xFFFFFF;
_hoverColor = 0x67A8C1;
_seekColor = 0x7c7c7c;
_controlSize = 40;
_percentLoaded = 0.0;
_hideControlsTimer = new Timer(500);
_hideAspectRatioLabelTimer = new Timer(500);
_controlsVisible = false;
_textFormat = new TextFormat();
_textFormat.font = "arial";
_textFormat.color = _controlColor;
_textFormat.size = 14;
//}
//{Playing controls initialization
_controlsBar = new Sprite();
_controlsBar.visible = true;
addChild(_controlsBar);
_playControl = new PlayIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_playControl);
_pauseControl = new PauseIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_pauseControl.visible = false;
_controlsBar.addChild(_pauseControl);
_aspectRatioControl = new AspectRatioIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_aspectRatioControl);
_fullscreenControl = new FullscreenIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_fullscreenControl);
_volumeIcon = new VolumeIcon(0, 0, 0, 0, _controlColor, _hoverColor);
_controlsBar.addChild(_volumeIcon);
_volumeSlider = new Sprite();
_volumeSlider.visible = false;
_controlsBar.addChild(_volumeSlider);
_volumeTrack = new Sprite();
_volumeTrack.visible = false;
_volumeTrack.buttonMode = true;
_volumeTrack.useHandCursor = true;
_volumeTrack.tabEnabled = false;
_controlsBar.addChild(_volumeTrack);
//}
//{Seeking Controls initialization
_seekBar = new Sprite();
_controlsBar.addChild(_seekBar);
_trackDownloaded = new Sprite( );
_trackDownloaded.tabEnabled = false;
_seekBar.addChild(_trackDownloaded);
_track = new Sprite( );
_track.tabEnabled = false;
_track.buttonMode = true;
_track.useHandCursor = true;
_seekBar.addChild(_track);
_thumb = new Sprite( );
_thumb.buttonMode = true;
_thumb.useHandCursor = true;
_thumb.tabEnabled = false;
_seekBar.addChild(_thumb);
_currentPlayTimeLabel = new TextField();
_currentPlayTimeLabel.autoSize = TextFieldAutoSize.LEFT;
_currentPlayTimeLabel.text = "00:00:00";
_currentPlayTimeLabel.tabEnabled = false;
_currentPlayTimeLabel.setTextFormat(_textFormat);
_seekBar.addChild(_currentPlayTimeLabel);
_totalPlayTimeLabel = new TextField();
_totalPlayTimeLabel.autoSize = TextFieldAutoSize.LEFT;
_totalPlayTimeLabel.text = "00:00:00";
_totalPlayTimeLabel.tabEnabled = false;
_totalPlayTimeLabel.setTextFormat(_textFormat);
_seekBar.addChild(_totalPlayTimeLabel);
_seekPlayTimeLabel = new TextField();
_seekPlayTimeLabel.visible = false;
_seekPlayTimeLabel.autoSize = TextFieldAutoSize.LEFT;
_seekPlayTimeLabel.text = "00:00:00";
_seekPlayTimeLabel.tabEnabled = false;
_seekPlayTimeLabel.setTextFormat(_textFormat);
addChild(_seekPlayTimeLabel);
//}
//{Aspect ratio label
_aspectRatioLabelContainer = new Sprite();
addChild(_aspectRatioLabelContainer);
_aspectRatioLabel = new TextField();
_aspectRatioLabel.autoSize = TextFieldAutoSize.CENTER;
_aspectRatioLabel.text = "original";
_aspectRatioLabel.tabEnabled = false;
_aspectRatioLabelContainer.addChild(_aspectRatioLabel);
//}
redrawControls();
//{Loader bar
_loader = new Loader();
_loader.hide();
var loaderColors:Array = ["", "", "", ""];
loaderColors[0] = Std.string(_darkColor);
loaderColors[1] = Std.string(_controlColor);
loaderColors[2] = Std.string(_seekColor);
_loader.setColors(loaderColors);
addChild(_loader);
//}
//{event Listeners
_movieClip.addEventListener(Event.ENTER_FRAME, onEnterFrame);
_thumb.addEventListener(MouseEvent.MOUSE_DOWN, onThumbMouseDown);
_thumb.addEventListener(MouseEvent.MOUSE_UP, onThumbMouseUp);
_thumb.addEventListener(MouseEvent.MOUSE_OVER, onThumbHover);
_thumb.addEventListener(MouseEvent.MOUSE_OUT, onThumbMouseOut);
_thumb.addEventListener(MouseEvent.MOUSE_MOVE, onTrackMouseMove);
_thumb.addEventListener(MouseEvent.MOUSE_OUT, onTrackMouseOut);
_track.addEventListener(MouseEvent.CLICK, onTrackClick);
_track.addEventListener(MouseEvent.MOUSE_MOVE, onTrackMouseMove);
_track.addEventListener(MouseEvent.MOUSE_OUT, onTrackMouseOut);
_playControl.addEventListener(MouseEvent.CLICK, onPlayClick);
_pauseControl.addEventListener(MouseEvent.CLICK, onPauseClick);
_aspectRatioControl.addEventListener(MouseEvent.CLICK, onAspectRatioClick);
_fullscreenControl.addEventListener(MouseEvent.CLICK, onFullscreenClick);
_volumeIcon.addEventListener(MouseEvent.CLICK, onVolumeIconClick);
_volumeTrack.addEventListener(MouseEvent.CLICK, onVolumeTrackClick);
_player.addEventListener(PlayerEvents.MOUSE_HIDE, onPlayerMouseHide);
_player.addEventListener(PlayerEvents.MOUSE_SHOW, onPlayerMouseShow);
_player.addEventListener(PlayerEvents.MEDIA_INITIALIZED, onPlayerMediaInitialized);
_player.addEventListener(PlayerEvents.BUFFERING, onPlayerBuffering);
_player.addEventListener(PlayerEvents.NOT_BUFFERING, onPlayerNotBuffering);
_player.addEventListener(PlayerEvents.RESIZE, onPlayerResize);
_player.addEventListener(PlayerEvents.PLAY_PAUSE, onPlayerPlayPause);
_player.addEventListener(PlayerEvents.PLAYBACK_FINISHED, onPlayerPlaybackFinished);
_player.addEventListener(PlayerEvents.CONNECTION_FAILED, onPlayerStreamNotFound);
_player.addEventListener(PlayerEvents.ASPECT_RATIO, onPlayerAspectRatio);
_stage.addEventListener(MouseEvent.MOUSE_UP, onThumbMouseUp);
_stage.addEventListener(MouseEvent.MOUSE_OUT, onThumbMouseUp);
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
_stage.addEventListener(Event.RESIZE, onStageResize);
_hideControlsTimer.addEventListener(TimerEvent.TIMER, hideControlsTimer);
_hideAspectRatioLabelTimer.addEventListener(TimerEvent.TIMER, hideAspectRatioLabelTimer);
_hideControlsTimer.start();
//}
}
//}
//{Timers
/**
* Hides the playing controls when not moving mouse.
* @param event The timer event associated
*/
private function hideControlsTimer(event:TimerEvent):Void
{
if (_player.isPlaying())
{
if (_controlsVisible)
{
if (_stage.mouseX <= 1 ||
_stage.mouseX >= _stage.stageWidth - 1 ||
_stage.mouseY >= _stage.stageHeight - 1 ||
_stage.mouseY < _controlsBar.y
)
{
_controlsVisible = false;
}
}
else
{
hideControls();
_hideControlsTimer.stop();
}
}
}
/**
* Hides aspect ratio label
* @param event
*/
private function hideAspectRatioLabelTimer(event:TimerEvent):Void
{
//wait till fade in effect finish
if (_aspectRatioLabelContainer.alpha >= 1)
{
Animation.fadeOut(_aspectRatioLabelContainer, 300);
_hideAspectRatioLabelTimer.stop();
}
}
//}
//{Events
/**
* Keeps syncronized various elements of the controls like the thumb and download track bar
* @param event
*/
private function onEnterFrame(event:Event):Void
{
if(_player.getDuration() > 0) {
if (_scrubbing)
{
_player.seek(((_thumb.x - _track.x) / _track.width) * _player.getDuration());
}
else
{
_currentPlayTimeLabel.text = Utils.formatTime(_player.getCurrentTime());
_currentPlayTimeLabel.setTextFormat(_textFormat);
_thumb.x = _player.getCurrentTime() / _player.getDuration() * (_track.width-_thumb.width) + _track.x;
}
}
_volumeSlider.height = _volumeTrack.height * (_player.getVolume() / 1.0);
_volumeSlider.y = (_volumeTrack.y + _volumeTrack.height) - _volumeSlider.height;
drawDownloadProgress();
}
/**
* Show playing controls on mouse movement.
* @param event
*/
private function onMouseMove(event:MouseEvent):Void
{
if (_stage.mouseY >= _controlsBar.y)
{
if (!_hideControlsTimer.running)
{
_hideControlsTimer.start();
}
_controlsVisible = true;
showControls();
}
}
/**
* Function fired by a stage resize eventthat redraws the player controls
* @param event
*/
private function onStageResize(event:Event):Void
{
redrawControls();
}
/**
* Toggles pause or play
* @param event
*/
private function onPlayClick(event:MouseEvent):Void
{
_player.togglePlay();
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Toggles pause or play
* @param event
*/
private function onPauseClick(event:MouseEvent):Void
{
_player.togglePlay();
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Toggles betewen aspect ratios
* @param event
*/
private function onAspectRatioClick(event:MouseEvent):Void
{
_player.toggleAspectRatio();
}
/**
* Toggles between window and fullscreen mode
* @param event
*/
private function onFullscreenClick(event:MouseEvent):Void
{
_player.toggleFullscreen();
}
/**
* Toggles between mute and unmute
* @param event
*/
private function onVolumeIconClick(event: MouseEvent):Void
{
if (_volumeSlider.visible) {
_volumeSlider.visible = false;
_volumeTrack.visible = false;
} else {
_volumeSlider.visible = true;
_volumeTrack.visible = true;
}
}
/**
* Detect user click on volume track control and change volume according
* @param event
*/
private function onVolumeTrackClick(event:MouseEvent):Void
{
var percent:Float = _volumeTrack.height - _volumeTrack.mouseY;
var volume:Float = 1.0 * (percent / _volumeTrack.height);
_player.setVolume(volume);
}
/**
* Display not found message
* @param event
*/
private function onPlayerStreamNotFound(event:PlayerEvents):Void
{
//todo: to work on this
}
/**
* Shows the loader bar when buffering
* @param event
*/
private function onPlayerBuffering(event:PlayerEvents):Void
{
_loader.show();
}
/**
* Hides loader bar when not buffering
* @param event
*/
private function onPlayerNotBuffering(event:PlayerEvents):Void
{
_loader.hide();
}
/**
* Show the selected aspect ratio
* @param event
*/
private function onPlayerAspectRatio(event:PlayerEvents):Void
{
_hideAspectRatioLabelTimer.stop();
_aspectRatioLabel.text = _player.getAspectRatioString();
drawAspectRatioLabel();
while (_aspectRatioLabelContainer.visible)
{
//wait till fade out finishes
}
Animation.fadeIn(_aspectRatioLabelContainer, 1);
_hideAspectRatioLabelTimer.start();
}
/**
* Monitors playbeack when finishes tu update controls
* @param event
*/
private function onPlayerPlaybackFinished(event:PlayerEvents):Void
{
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
showControls();
}
/**
* Monitors keyboard play pause actions to update icons
* @param event
*/
private function onPlayerPlayPause(event:PlayerEvents):Void
{
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Resizes the video player on windowed mode substracting the seekbar height
* @param event
*/
private function onPlayerResize(event:PlayerEvents):Void
{
}
/**
* Updates media total time duration.
* @param event
*/
private function onPlayerMediaInitialized(event:PlayerEvents):Void
{
_totalPlayTimeLabel.text = Utils.formatTime(event.duration);
_totalPlayTimeLabel.setTextFormat(_textFormat);
_playControl.visible = !_player.isPlaying();
_pauseControl.visible = _player.isPlaying();
}
/**
* Hides seekbar if on fullscreen.
* @param event
*/
private function onPlayerMouseHide(event:PlayerEvents):Void
{
if (_controlsBar.visible && _player.isFullscreen())
{
hideControls();
}
}
/**
* Shows seekbar
* @param event
*/
private function onPlayerMouseShow(event:PlayerEvents):Void
{
//Only use slidein effect on fullscreen since switching to windowed mode on
//hardware scaling causes a bug by a slow response on stage height changes
if (_player.isFullscreen() && !_controlsBar.visible)
{
_controlsBar.visible = true;
}
else if (!_controlsBar.visible)
{
_controlsBar.visible = true;
}
}
/**
* Translates a user click in to time and seeks to it
* @param event
*/
private function onTrackClick(event:MouseEvent):Void
{
var clickPosition:Float = _track.mouseX;
_player.seek(_player.getDuration() * (clickPosition / _track.width));
}
/**
* Shows a small tooltip showing the time calculated by mouse position
* @param event
*/
private function onTrackMouseMove(event:MouseEvent):Void
{
var clickPosition:Float = _track.mouseX;
_seekPlayTimeLabel.text = Utils.formatTime(_player.getDuration() * (clickPosition / _track.width));
_seekPlayTimeLabel.setTextFormat(_textFormat);
_seekPlayTimeLabel.y = _stage.stageHeight - _seekBar.height - _seekPlayTimeLabel.height - 1;
_seekPlayTimeLabel.x = clickPosition + (_seekPlayTimeLabel.width / 2) + (_playControl.width + 10) * 2;
_seekPlayTimeLabel.backgroundColor = _darkColor;
_seekPlayTimeLabel.background = true;
_seekPlayTimeLabel.textColor = _controlColor;
_seekPlayTimeLabel.borderColor = _darkColor;
_seekPlayTimeLabel.border = true;
if (!_seekPlayTimeLabel.visible)
{
_seekPlayTimeLabel.visible = true;
}
}
/**
* Hides the tooltip that shows the time calculated by mouse position
* @param event
*/
private function onTrackMouseOut(event:MouseEvent):Void
{
_seekPlayTimeLabel.visible = false;
}
/**
* Enables dragging of thumb for seeking media
* @param event
*/
private function onThumbMouseDown(event:MouseEvent):Void
{
_scrubbing = true;
var rectangle:Rectangle = new Rectangle(_track.x, _track.y, _track.width-_thumb.width, 0);
_thumb.startDrag(false, rectangle);
}
/**
* Changes thumb seek control to hover color
* @param event
*/
private function onThumbHover(event:MouseEvent):Void
{
_thumb.graphics.lineStyle();
_thumb.graphics.beginFill(_hoverColor);
_thumb.graphics.drawRoundRect(0, (_seekBar.height/2)-(11/2), 11, 11, 10, 10);
_thumb.graphics.endFill();
}
/**
* Changes thumb seek control to control color
* @param event
*/
private function onThumbMouseOut(event:MouseEvent):Void
{
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(11, 11, Utils.degreesToRadians(-90), 11, 0);
var colors:Array = [_controlColor, _controlColor];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
_thumb.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
_thumb.graphics.drawRoundRect(0, (_seekBar.height / 2) - (11 / 2), 11, 11, 10, 10);
_thumb.graphics.endFill();
}
/**
* Disables dragging of thumb
* @param event
*/
private function onThumbMouseUp(event:MouseEvent):Void
{
_scrubbing = false;
_thumb.stopDrag( );
}
//}
//{Drawing functions
/**
* Clears all current graphics a draw new ones
*/
private function redrawControls():Void
{
drawControls();
drawAspectRatioLabel();
}
/**
* Draws the download progress track bar
*/
private function drawDownloadProgress():Void
{
if (_player.getBytesTotal() > 0)
{
var bytesLoaded:Float = _player.getBytesLoaded();
var bytesTotal:Float = _player.getBytesTotal();
_percentLoaded = bytesLoaded / bytesTotal;
}
var position:Float = _player.getStartTime() / _player.getDuration();
var startPosition:Float = (position > 0?(position * _track.width):0) + _track.x;
_trackDownloaded.graphics.clear();
_trackDownloaded.graphics.lineStyle();
_trackDownloaded.x = startPosition;
_trackDownloaded.graphics.beginFill(_seekColor, 0.5);
_trackDownloaded.graphics.drawRoundRect(0, (_seekBar.height / 2) - (5 / 2), ((_track.width + _track.x) - _trackDownloaded.x) * _percentLoaded, 5, 3, 3);
_trackDownloaded.graphics.endFill();
}
/**
* Draws NEW control bar player/seek controls
*/
private function drawControls():Void
{
//Reset sprites for redraw
_controlsBar.graphics.clear();
_volumeTrack.graphics.clear();
_volumeSlider.graphics.clear();
_volumeSlider.visible = false;
_volumeTrack.visible = false;
//Reset sprites for redraw
_seekBar.graphics.clear();
_track.graphics.clear();
_thumb.graphics.clear();
//Draw controls bar
var barMargin = 10;
var barWidth = _stage.stageWidth;
var barHeight = _controlSize;
var barCenter = barWidth / 2;
var buttonSize = Std.int(((80 / 100) * (barHeight - (barMargin*2))));
_controlsBar.x = 0;
_controlsBar.y = (_stage.stageHeight - barHeight);
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(barWidth, barHeight, Utils.degreesToRadians(-90), barWidth, 0);
var colors:Array = [_brightColor, _darkColor];
var alphas:Array = [1.0, 1];
var ratios:Array = [0, 255];
_controlsBar.graphics.lineStyle();
_controlsBar.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
_controlsBar.graphics.drawRect(0, 2, barWidth, barHeight-2);
_controlsBar.graphics.endFill();
_controlsBar.graphics.beginFill(_darkColor, 1);
_controlsBar.graphics.drawRect(0, 0, barWidth, 1);
_controlsBar.graphics.endFill();
_controlsBar.graphics.beginFill(_brightColor, 1);
_controlsBar.graphics.drawRect(0, 1, barWidth, 1);
_controlsBar.graphics.endFill();
//Draw seek bar
var _seekBarWidth = barWidth - (buttonSize+barMargin)*3 - (_playControl.x + _playControl.width + barMargin) - barMargin;
var _seekBarHeight = barHeight;
_seekBar.x = _playControl.x + _playControl.width + barMargin;
_seekBar.y = 0;
_seekBar.graphics.lineStyle();
_seekBar.graphics.beginFill(_darkColor, 0);
_seekBar.graphics.drawRect(0, 0, _seekBarWidth, _seekBarHeight);
_seekBar.graphics.endFill();
//Draw playbutton
_playControl.setNormalColor(_controlColor);
_playControl.setHoverColor(_hoverColor);
_playControl.setPosition(barMargin, barMargin);
_playControl.setSize(buttonSize+5, buttonSize+5);
//Draw pausebutton
_pauseControl.setNormalColor(_controlColor);
_pauseControl.setHoverColor(_hoverColor);
_pauseControl.setPosition(_playControl.x, _playControl.y);
_pauseControl.setSize(buttonSize+5, buttonSize+5);
//Draw current play time label
_textFormat.color = _seekColor;
_currentPlayTimeLabel.x = 0;
_currentPlayTimeLabel.y = _seekBarHeight - (_seekBarHeight / 2) - (_currentPlayTimeLabel.height / 2);
_currentPlayTimeLabel.antiAliasType = AntiAliasType.ADVANCED;
_currentPlayTimeLabel.setTextFormat(_textFormat);
//Draw total play time label
_totalPlayTimeLabel.x = _seekBarWidth - _totalPlayTimeLabel.width;
_totalPlayTimeLabel.y = _seekBarHeight - (_seekBarHeight / 2) - (_totalPlayTimeLabel.height / 2);
_totalPlayTimeLabel.antiAliasType = AntiAliasType.ADVANCED;
_totalPlayTimeLabel.setTextFormat(_textFormat);
//Draw download progress
drawDownloadProgress();
//Draw track place holder for drag
_track.x = _currentPlayTimeLabel.x + _currentPlayTimeLabel.width + barMargin;
_track.graphics.lineStyle();
_track.graphics.beginFill(_seekColor, 0);
_track.graphics.drawRect(0, (_seekBarHeight / 2) - ((buttonSize+barMargin) / 2), _totalPlayTimeLabel.x - _totalPlayTimeLabel.width - barMargin - barMargin, buttonSize + barMargin);
_track.graphics.endFill();
_track.graphics.lineStyle();
_track.graphics.beginFill(_seekColor, 0.3);
_track.graphics.drawRoundRect(0, (_seekBarHeight / 2) - (5 / 2), _totalPlayTimeLabel.x - _totalPlayTimeLabel.width - barMargin - barMargin, 5, 3, 3);
_track.graphics.endFill();
//Draw thumb
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(11, 11, Utils.degreesToRadians(-90), 11, 0);
var colors:Array = [_controlColor, _controlColor];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
_thumb.x = _currentPlayTimeLabel.width + _currentPlayTimeLabel.x + barMargin;
_thumb.graphics.lineStyle();
_thumb.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//_thumb.graphics.beginFill(_controlColor);
_thumb.graphics.drawRoundRect(0, (_seekBarHeight/2)-(11/2), 11, 11, 10, 10);
_thumb.graphics.endFill();
//Draw volume icon
_volumeIcon.setNormalColor(_controlColor);
_volumeIcon.setHoverColor(_hoverColor);
_volumeIcon.setPosition(_seekBar.x + _seekBar.width + barMargin, _playControl.y+1);
_volumeIcon.setSize(buttonSize, buttonSize);
//Draw aspec ratio button
_aspectRatioControl.setNormalColor(_controlColor);
_aspectRatioControl.setHoverColor(_hoverColor);
_aspectRatioControl.setPosition(_volumeIcon.x + _volumeIcon.width + barMargin, _playControl.y+1);
_aspectRatioControl.setSize(buttonSize, buttonSize);
//Draw fullscreen button
_fullscreenControl.setNormalColor(_controlColor);
_fullscreenControl.setHoverColor(_hoverColor);
_fullscreenControl.setPosition(_aspectRatioControl.x + _aspectRatioControl.width + barMargin, _playControl.y+1);
_fullscreenControl.setSize(buttonSize, buttonSize);
//Draw volume track
_volumeTrack.x = _controlsBar.width-(buttonSize+barMargin)*3;
_volumeTrack.y = -_controlsBar.height-2;
_volumeTrack.graphics.lineStyle(1, _controlColor);
_volumeTrack.graphics.beginFill(0x000000, 0);
_volumeTrack.graphics.drawRect(0, 0, buttonSize, _controlsBar.height);
_volumeTrack.graphics.endFill();
//Draw volume slider
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_volumeTrack.width, _volumeTrack.height, Utils.degreesToRadians(-90), _volumeTrack.width, 0);
var colors:Array = [_hoverColor, _hoverColor];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
_volumeSlider.x = _volumeTrack.x;
_volumeSlider.y = _volumeTrack.y;
_volumeSlider.graphics.lineStyle();
_volumeSlider.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//_volumeSlider.graphics.beginFill(_hoverColor, 1);
_volumeSlider.graphics.drawRect(0, 0, _volumeTrack.width, _volumeTrack.height);
_volumeSlider.graphics.endFill();
}
private function drawAspectRatioLabel():Void
{
_aspectRatioLabelContainer.graphics.clear();
_aspectRatioLabelContainer.visible = false;
//Update aspect ratio label
var textFormat:TextFormat = new TextFormat();
textFormat.font = "arial";
textFormat.bold = true;
textFormat.size = 40;
textFormat.color = _controlColor;
_aspectRatioLabel.setTextFormat(textFormat);
_aspectRatioLabel.x = (_stage.stageWidth / 2) - (_aspectRatioLabel.width / 2);
_aspectRatioLabel.y = (_stage.stageHeight / 2) - (_aspectRatioLabel.height / 2);
//Draw aspect ratio label container
_aspectRatioLabelContainer.x = _aspectRatioLabel.x - 10;
_aspectRatioLabelContainer.y = _aspectRatioLabel.y - 10;
_aspectRatioLabelContainer.graphics.lineStyle(0, _darkColor);
_aspectRatioLabelContainer.graphics.beginFill(_darkColor, 1);
_aspectRatioLabelContainer.graphics.drawRoundRect(0, 0, _aspectRatioLabel.width + 20, _aspectRatioLabel.height + 20, 15, 15);
_aspectRatioLabelContainer.graphics.endFill();
_aspectRatioLabel.x = 10;
_aspectRatioLabel.y = 10;
}
//}
//{Private Methods
/**
* Hide the play controls bar
*/
private function hideControls():Void
{
if(_controlsBar.visible)
{
drawControls();
Animation.slideOut(_controlsBar, "bottom", 800);
}
}
/**
* Shows play controls bar
*/
private function showControls():Void
{
if(!_controlsBar.visible)
{
drawControls();
_controlsBar.visible = true;
}
}
//}
//{Setters
/**
* Sets the player colors and redraw them
* @param colors Array of colors in the following order: darkColor, brightColor, controlColor, hoverColor
*/
public function setControlColors(colors:Array):Void
{
_darkColor = colors[0].length > 0? Std.parseInt("0x" + colors[0]) : 0x000000;
_brightColor = colors[1].length > 0? Std.parseInt("0x" + colors[1]) : 0x4c4c4c;
_controlColor = colors[2].length > 0? Std.parseInt("0x" + colors[2]) : 0xFFFFFF;
_hoverColor = colors[3].length > 0? Std.parseInt("0x" + colors[3]) : 0x67A8C1;
_seekColor = colors[4].length > 0? Std.parseInt("0x" + colors[4]) : 0x7c7c7c;
var loaderColors:Array = ["", ""];
loaderColors[0] = colors[0];
loaderColors[1] = colors[2];
loaderColors[2] = colors[4];
_loader.setColors(loaderColors);
redrawControls();
}
/**
* Sets the player controls size (height)
* @param size int: for e.g. 50
*/
public function setControlSize(size:Int):Void
{
if (size == 0)
return;
_controlSize = size;
redrawControls();
}
/**
* To set the duration label when autostart parameter is false
* @param duration in seconds or formatted string in format hh:mm:ss
*/
public function setDurationLabel(duration:String):Void
{
//Person passed time already formatted
if (duration.indexOf(":") != -1)
{
_totalPlayTimeLabel.text = duration;
}
//Time passed in seconds
else
{
_totalPlayTimeLabel.text = Std.string(Utils.formatTime(Std.parseFloat(duration)));
}
_totalPlayTimeLabel.setTextFormat(_textFormat);
}
//}
}
v2.0.17~dfsg/src/jaris/player/newcontrols/FullscreenIcon.hx 0000755 0000000 0000000 00000007356 12625374554 022610 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import jaris.utils.Utils;
import flash.display.GradientType;
class FullscreenIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(0, color, 0.0);
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
var arrowWidth = Std.int(_width / 2 * 0.8);
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_width, _height, Utils.degreesToRadians(-90), _width, 0);
var colors:Array = [color, color];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
graphics.lineStyle(0, color, 0, true);
graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//graphics.beginFill(color, 0);
graphics.drawRect(0, 0, arrowWidth, 2);
graphics.drawRect(0, 2, 2, arrowWidth-2);
graphics.drawRect(_width-arrowWidth+1, 0, arrowWidth, 2);
graphics.drawRect(_width-1, 2, 2, arrowWidth-2);
graphics.drawRect(0, _height-arrowWidth+2, 2, arrowWidth);
graphics.drawRect(2, _height, arrowWidth-2, 2);
graphics.drawRect(_width-1, _height-arrowWidth+2, 2, arrowWidth-2);
graphics.drawRect(_width-arrowWidth+1, _height, arrowWidth, 2);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/newcontrols/Loader.hx 0000755 0000000 0000000 00000013175 12625374554 021077 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.Lib;
import flash.geom.Matrix;
import jaris.utils.Utils;
import flash.display.GradientType;
/**
* Draws a loading bar
*/
class Loader extends Sprite
{
private var _stage:Stage;
private var _movieClip:MovieClip;
private var _background:Sprite;
private var _loaderTrack:Sprite;
private var _loaderThumb:Sprite;
private var _visible:Bool;
private var _darkColor:UInt;
private var _controlColor:UInt;
private var _seekColor:UInt;
private var _forward:Bool;
public function new()
{
super();
_stage = Lib.current.stage;
_movieClip = Lib.current;
_background = new Sprite();
addChild(_background);
_loaderTrack = new Sprite();
addChild(_loaderTrack);
_loaderThumb = new Sprite();
addChild(_loaderThumb);
_darkColor = 0x000000;
_controlColor = 0xFFFFFF;
_seekColor = 0x747474;
_forward = true;
_visible = true;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
_stage.addEventListener(Event.RESIZE, onResize);
drawLoader();
}
/**
* Animation of a thumb moving on the track
* @param event
*/
private function onEnterFrame(event:Event):Void
{
if (_visible)
{
if (_forward)
{
if ((_loaderThumb.x + _loaderThumb.width) >= (_loaderTrack.x + _loaderTrack.width))
{
_forward = false;
}
else
{
_loaderThumb.x += 10;
}
}
else
{
if (_loaderThumb.x <= _loaderTrack.x)
{
_forward = true;
}
else
{
_loaderThumb.x -= 10;
}
}
}
}
/**
* Redraws the loader to match new stage size
* @param event
*/
private function onResize(event:Event):Void
{
drawLoader();
}
/**
* Draw loader graphics
*/
private function drawLoader():Void
{
//Clear graphics
_background.graphics.clear();
_loaderTrack.graphics.clear();
_loaderThumb.graphics.clear();
//Draw background
var backgroundWidth:Float = (65 / 100) * _stage.stageWidth;
var backgroundHeight:Float = 30;
_background.x = (_stage.stageWidth / 2) - (backgroundWidth / 2);
_background.y = (_stage.stageHeight / 2) - (backgroundHeight / 2);
_background.graphics.lineStyle();
_background.graphics.beginFill(_darkColor, 0.75);
_background.graphics.drawRoundRect(0, 0, backgroundWidth, backgroundHeight, 6, 6);
_background.graphics.endFill();
//Draw track
var trackWidth:Float = (50 / 100) * _stage.stageWidth;
var trackHeight:Float = 11;
_loaderTrack.x = (_stage.stageWidth / 2) - (trackWidth / 2);
_loaderTrack.y = (_stage.stageHeight / 2) - (trackHeight / 2);
_loaderTrack.graphics.lineStyle();
_loaderTrack.graphics.beginFill(_seekColor, 0.3);
_loaderTrack.graphics.drawRoundRect(0, trackHeight/2/2, trackWidth, trackHeight/2, 5, 5);
//Draw thumb
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(trackHeight*3, trackHeight, Utils.degreesToRadians(-90), trackHeight*3, 0);
var colors:Array = [_controlColor, _controlColor];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
_loaderThumb.x = _loaderTrack.x;
_loaderThumb.y = _loaderTrack.y;
_loaderThumb.graphics.lineStyle();
_loaderThumb.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//_loaderThumb.graphics.beginFill(_controlColor, 1);
_loaderThumb.graphics.drawRoundRect(0, 0, trackHeight*3, trackHeight, 10, 10);
}
/**
* Stops drawing the loader
*/
public function hide():Void
{
this.visible = false;
_visible = false;
}
/**
* Starts drawing the loader
*/
public function show():Void
{
this.visible = true;
_visible = true;
}
/**
* Set loader colors
* @param colors
*/
public function setColors(colors:Array):Void
{
_darkColor = colors[0].length > 0? Std.parseInt("0x" + colors[0]) : 0x000000;
_controlColor = colors[1].length > 0? Std.parseInt("0x" + colors[1]) : 0xFFFFFF;
_seekColor = colors[2].length > 0? Std.parseInt("0x" + colors[2]) : 0x747474;
drawLoader();
}
}
v2.0.17~dfsg/src/jaris/player/newcontrols/PlayIcon.hx 0000755 0000000 0000000 00000006444 12625374554 021410 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player.newcontrols;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import jaris.utils.Utils;
import flash.display.GradientType;
class PlayIcon extends Sprite
{
private var _width:Float;
private var _height:Float;
private var _normalColor:UInt;
private var _hoverColor:UInt;
public function new(x:Float, y:Float, width:Float, height:Float, normalColor:UInt, hoverColor:UInt)
{
super();
this.x = x;
this.y = y;
this.buttonMode = true;
this.useHandCursor = true;
this.tabEnabled = false;
_width = width;
_height = height;
_normalColor = normalColor;
_hoverColor = hoverColor;
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
draw(_normalColor);
}
private function onMouseOver(event:MouseEvent):Void
{
draw(_hoverColor);
}
private function onMouseOut(event:MouseEvent):Void
{
draw(_normalColor);
}
//{Private Methods
private function draw(color:UInt):Void
{
graphics.clear();
graphics.lineStyle(0, color, 0.0);
graphics.beginFill(color, 0);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
var matrix:Matrix = new Matrix( );
matrix.createGradientBox(_width, _height, Utils.degreesToRadians(-90), _width, 0);
var colors:Array = [color, color];
var alphas:Array = [0.75, 1];
var ratios:Array = [0, 255];
graphics.lineStyle();
graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
//graphics.beginFill(color);
graphics.lineTo(0, _height);
graphics.lineTo(_width, _height / 2);
graphics.lineTo(0, 0);
graphics.endFill();
}
//}
//{Setters
public function setNormalColor(color:UInt):Void
{
_normalColor = color;
draw(_normalColor);
}
public function setHoverColor(color:UInt):Void
{
_hoverColor = color;
draw(_hoverColor);
}
public function setPosition(x:Float, y:Float):Void
{
this.x = x;
this.y = y;
draw(_normalColor);
}
public function setSize(width:Float, height:Float):Void
{
_width = width;
_height = height;
draw(_normalColor);
}
//}
}
v2.0.17~dfsg/src/jaris/player/InputType.hx 0000644 0000000 0000000 00000002037 12625374554 017245 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris.player;
/**
* Stores the identifiers for loaded media type
*/
class InputType
{
public static var AUDIO = "audio";
public static var VIDEO = "video";
}
v2.0.17~dfsg/src/jaris/Main.hx 0000644 0000000 0000000 00000020073 12625374554 014674 0 ustar root root /**
* @author Jefferson González
* @copyright 2010 Jefferson González
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
package jaris;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.Lib;
import flash.system.Capabilities;
import jaris.display.Logo;
import jaris.display.Menu;
import jaris.display.Poster;
import jaris.player.controls.Controls;
import jaris.player.newcontrols.NewControls;
import jaris.player.JsApi;
import jaris.player.InputType;
import jaris.player.Player;
import jaris.player.StreamType;
import jaris.player.AspectRatio;
import jaris.player.UserSettings;
import jaris.player.Loop;
/**
* Main jaris player starting point
*/
class Main
{
static var stage:Stage;
static var movieClip:MovieClip;
static function main():Void
{
//Initialize stage and main movie clip
stage = Lib.current.stage;
movieClip = Lib.current;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//Retrieve user settings
var userSettings:UserSettings = new UserSettings();
//Reads flash vars
var parameters:Dynamic = flash.Lib.current.loaderInfo.parameters;
//Initialize and draw player object
var player:Player = new Player();
if (Capabilities.playerType == "PlugIn" || Capabilities.playerType == "ActiveX")
{
var autoStart:Bool = parameters.autostart == "true" || parameters.autostart == "" || parameters.autostart == null? true: false;
var type:String = parameters.type != "" && parameters.type != null? parameters.type : InputType.VIDEO;
var streamType:String = parameters.streamtype != "" && parameters.streamtype != null? parameters.streamtype : StreamType.FILE;
var server:String = parameters.server != "" && parameters.server != null? parameters.server : "";
var aspectRatio:String = parameters.aspectratio != "" && parameters.aspectratio != null? parameters.aspectratio : "";
var bufferTime:Float = parameters.buffertime != "" && parameters.buffertime != null? Std.parseFloat(parameters.buffertime) : 0;
if (aspectRatio != "" && !userSettings.isSet("aspectratio"))
{
switch(aspectRatio)
{
case "1:1":
player.setAspectRatio(AspectRatio._1_1);
case "3:2":
player.setAspectRatio(AspectRatio._3_2);
case "4:3":
player.setAspectRatio(AspectRatio._4_3);
case "5:4":
player.setAspectRatio(AspectRatio._5_4);
case "14:9":
player.setAspectRatio(AspectRatio._14_9);
case "14:10":
player.setAspectRatio(AspectRatio._14_10);
case "16:9":
player.setAspectRatio(AspectRatio._16_9);
case "16:10":
player.setAspectRatio(AspectRatio._16_10);
}
}
else if(userSettings.isSet("aspectratio"))
{
player.setAspectRatio(userSettings.getAspectRatio());
}
player.setType(type);
player.setStreamType(streamType);
player.setServer(server);
player.setVolume(userSettings.getVolume());
player.setBufferTime(bufferTime);
if (autoStart)
{
player.load(parameters.source, type, streamType, server);
}
else
{
player.setSource(parameters.source);
}
player.setHardwareScaling(parameters.hardwarescaling=="true"?true:false);
}
else
{
//For development purposes
if(userSettings.isSet("aspectratio"))
{
player.setAspectRatio(userSettings.getAspectRatio());
}
player.setVolume(userSettings.getVolume());
player.load("http://jaris.sourceforge.net/files/jaris-intro.flv", InputType.VIDEO, StreamType.FILE);
//player.load("http://jaris.sourceforge.net/files/audio.mp3", InputType.AUDIO, StreamType.FILE);
}
//Draw preview image
if (parameters.poster != null)
{
var poster:String = parameters.poster;
var posterImage = new Poster(poster);
posterImage.setPlayer(player);
movieClip.addChild(posterImage);
}
//Modify Context Menu
var menu:Menu = new Menu(player);
//Draw logo
if (parameters.logo!=null)
{
var logoSource:String = parameters.logo != null ? parameters.logo : "logo.png";
var logoPosition:String = parameters.logoposition != null ? parameters.logoposition : "top left";
var logoAlpha:Float = parameters.logoalpha != null ? Std.parseFloat(parameters.logoalpha) / 100 : 0.3;
var logoWidth:Float = parameters.logowidth != null ? Std.parseFloat(parameters.logowidth) : 130;
var logoLink:String = parameters.logolink != null ? parameters.logolink : "http://jaris.sourceforge.net";
var logo:Logo = new Logo(logoSource, logoPosition, logoAlpha, logoWidth);
logo.setLink(logoLink);
movieClip.addChild(logo);
}
//Draw Controls
if (parameters.controls != "false")
{
var duration:String = parameters.duration != "" && parameters.duration != null? parameters.duration : "0";
var controlType:Int = parameters.controltype != "" && parameters.controltype != null? Std.parseInt(parameters.controltype) : 0;
var controlSize:Int = parameters.controlsize != "" && parameters.controlsize != null? Std.parseInt(parameters.controlsize) : 0;
var controlColors:Array = ["", "", "", "", ""];
controlColors[0] = parameters.darkcolor != null ? parameters.darkcolor : "";
controlColors[1] = parameters.brightcolor != null ? parameters.brightcolor : "";
controlColors[2] = parameters.controlcolor != null ? parameters.controlcolor : "";
controlColors[3] = parameters.hovercolor != null ? parameters.hovercolor : "";
controlColors[4] = parameters.seekcolor != null ? parameters.seekcolor : "";
if (controlType == 1) {
var controls:NewControls = new NewControls(player);
controls.setDurationLabel(duration);
controls.setControlColors(controlColors);
controls.setControlSize(controlSize);
movieClip.addChild(controls);
} else {
var controls:Controls = new Controls(player);
controls.setDurationLabel(duration);
controls.setControlColors(controlColors);
movieClip.addChild(controls);
}
}
//Loop the video
if (parameters.loop != null)
{
var loop:Loop = new Loop(player);
}
//Expose events to javascript functions and enable controlling the player from the outside
if (parameters.jsapi != null)
{
var jsAPI:JsApi = new JsApi(player);
movieClip.addChild(jsAPI);
}
}
}
v2.0.17~dfsg/changes.txt 0000644 0000000 0000000 00000011506 12625374554 013722 0 ustar root root Jaris FLV Player v2.0.17 - 22/11/2015
* Disabled second parameter when calling play() on a rtmp source.
* Disabled rtmpSourceParser() because it is causing issues.
* Added rtmp notes to documentation.txt
* fix new control do not autohide bug thanks to Michelangelo
* fix new control vertical check thanks to Michelangelo
Jaris FLV Player v2.0.16 - 11/09/2014
* Fixes in order to compile with new haxe v3 thanks to jonassmedegaard
* Fix the AsyncErrorEvent exception thrown by player thanks to lcb931023
* Added loadVideo() JsAPI call, call from JS new video thanks to Spiritdude
* Added build.hxml
Jaris FLV Player v2.0.15 beta - 27/08/2011
* New player controls
* New flashvar controltype (0=old, 1=new) to indicate the which controls to use
* New flashvar controlsize for new controls only
* New flashvar seekcolor for new controls only
* New flashvar buffertime to change the default 10 seconds buffer time for local/pseudo streaming
* Bugfix on loader bar
* All this changes thanks to Istvan Petres from http://jcore.net
Jaris FLV Player v2.0.14 beta - 20/05/2011
* Removed some trace calls on youtube playback.
Jaris FLV Player v2.0.13 beta - 6/03/2011
* Implemented loop class
* Added loop functionality by passing loop=true or loop=1 as parameter
* Fixed reported bug "slider will show wrong position" on pseudostreaming seek (Thanks to Adam)
Jaris FLV Player v2.0.12 beta - 06/11/2010
* Java Script Api to listen for events and control the player.
* More player events added to use on JSApi.
* All this changes thanks to Sascha Kluger from http://projekktor.com
Jaris FLV Player v2.0.11 beta - 03/10/2010
* Removed togglePlay of onFullscreen event since it seems that new flash versions doesnt emits
the space keydown anymore that affected playback on fullcreen switching.
* Added class to store user settings as volume and aspect ratio to load them next time player is load.
Jaris FLV Player v2.0.10 beta - 29/09/2010
* Added flashvar aspectratio option to initially tell on wich aspect ratio to play the video
Jaris FLV Player v2.0.9 beta - 26/05/2010
* Improved poster to keep aspect ratio and display back when playback finishes
Jaris FLV Player v2.0.8 beta - 14/05/2010
* Fixed bug on formatTime function calculating hours as minutes
Jaris FLV Player v2.0.7 beta - 03/19/2010
* Fixed youtube security bug
Jaris FLV Player v2.0.6 beta - 03/13/2010
* Added: display current aspect ratio label on aspect ratio toggle
* Improved readability of text
* only attach netstream to video object if input type is video
* remove poster from player code
Jaris FLV Player v2.0.5 beta - 03/12/2010
* Improved aspect ratio toogle when video aspect ratio is already on the aspect ratios list
* Fixed context menu aspect ratio rotation
Jaris FLV Player v2.0.4 beta - 03/11/2010
* Fixed a drawing issue where seek bar after fullscreen stayed long
* Documented other parts of the code
Jaris FLV Player v2.0.3 beta - 03/10/2010
* Support for rtmp streaming
* support for youtube
* better support for http streaming like lighttpd
* Fixed calculation of width on original aspect ratio larger than stage
* And many hours of improvements
Jaris FLV Player v2.0.2 beta - 03/09/2010
* Implement EventDispatcher on Player class instead of using custom event mechanism
* Fixed not getting initial stage widht and height on IE when using swfobjects
* Some more improvements to controls on short heights
* Other improvements and code refactoring
* added id3 info to player events
Jaris FLV Player v2.0.1 beta - 03/08/2010
* Toggle Quality on Context Menu
* Introduction of type parameter
* Initial mp3 support
* Loader fixes
* Controls fixes
* Other refinements and fixes
* Duration parameter to indicate how much total time takes input media
Jaris FLV Player v2.0.0 beta - 03/05/2010
* Moved from swishmax 2 to haxe and flashdevelop
* New GUI completely written in haxe (AS3)
* Hide controls on fullscreen
* Recalculate aspect ratio on fullscreen.
* Redraw controls on fullscreen and normal switching.
* Initial pseudo streaming support
* Compiled to flash 10
* Now uses as3 libraries
* Optional Hardware scaling
* Video smoothing enabled by default
* Added custom context menu
* Other refinements and fixes
Jaris FLV Player v1.0 - 05/21/2008
* Calculates video aspect ratio on player load.
* Support Flash 9 Stage.displayState (Fullscreen mode).
* Support for preview image of the video.
* Display buffering message.
* Internal volume control.
* Back and forward control.
* Display the actual playing time and total time.
* Support for logo image on the fly.
* Flag to autostart the video on player load.
v2.0.17~dfsg/README.md 0000644 0000000 0000000 00000003275 12625374554 013034 0 ustar root root #Jaris FLV Player
A flash flv/mp4 player made using haxe and flash develop that can be embedded into any website
for free or commercial use. With support for rtmp, youtube, http streaming and many more features.
Open for improvements by you!
Web Page: http://jarisflvplayer.org/
Project Page: https://sourceforge.net/projects/jaris/
##Be Free!
Searching for an flv player that could be used freely in all aspects and open source was
a hard job. So I just decided to work on a basic player that had the most important
features found in others players.
Thats the story of how Jaris was born.
##Features
* Aspect ratio switcher
* Fullscreen support
* Http pseudostreaming support
* Basic RTMP streaming support
* Poster image
* Volume control
* Seek control
* Display time
* Use your own logo
* Add a link to your logo
* Change position of logo
* Hide controls on fullscreen
* Custom control colors
* Hardware scaling
* Keyboard shortcuts
* Mp3 support
##License
Jaris is licensed under GPL and LGPL, meaning that you could use it commercially.
What we ask for is that any improvements made to the player should be taken back to jaris flv website
so that any one could enjoy the new improvements or features also. In this way everyone could
help to maintain an up to date tool that adapts to todays multimedia demands.
Using github you can fork the project, work on your changes, and send a pull request.
Enjoy a totally free player ;-)
##Compiling from source
Install [haxe](http://haxe.org/) change to the directory where jaris sources reside
and run:
haxe build.xml
JarisFLVPlayer.swf will be generated on the **bin** directory which you can embed in
your web sites as integrate as part of other projects.
v2.0.17~dfsg/bin/ 0000755 0000000 0000000 00000000000 12626407204 012304 5 ustar root root v2.0.17~dfsg/bin/js/ 0000755 0000000 0000000 00000000000 12626407204 012720 5 ustar root root v2.0.17~dfsg/bin/js/jarisflvplayer.js 0000644 0000000 0000000 00000006402 12625374554 016327 0 ustar root root /**
* @author Jefferson Gonzalez
* @copyright 2010 Jefferson Gonzalez
*
* @license
* This file is part of Jaris FLV Player.
*
* Jaris FLV Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License or GNU LESSER GENERAL
* PUBLIC LICENSE as published by the Free Software Foundation, either version
* 3 of the License, or (at your option) any later version.
*
* Jaris FLV Player 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.
*
* You should have received a copy of the GNU General Public License and
* GNU LESSER GENERAL PUBLIC LICENSE along with Jaris FLV Player. If not,
* see .
*/
/**
*Interface for the JarisFLVPlayer JavaScript API implemented
*by Sascha from http://projekktor.com/
*@param id The id of the flash object
*/
function JarisFLVPlayer(id){
this.playerId = id; //Stores the id of the player
this.player = null; //Object that points to the player
}
//Event constants
JarisFLVPlayer.event = {
MOUSE_HIDE: "onMouseHide",
MOUSE_SHOW: "onMouseShow",
MEDIA_INITIALIZED: "onDataInitialized",
BUFFERING: "onBuffering",
NOT_BUFFERING: "onNotBuffering",
RESIZE: "onResize",
PLAY_PAUSE: "onPlayPause",
PLAYBACK_FINISHED: "onPlaybackFinished",
CONNECTION_FAILED: "onConnectionFailed",
ASPECT_RATIO: "onAspectRatio",
VOLUME_UP: "onVolumeUp",
VOLUME_DOWN: "onVolumeDown",
VOLUME_CHANGE: "onVolumeChange",
MUTE: "onMute",
TIME: "onTimeUpdate",
PROGRESS: "onProgress",
SEEK: "onSeek",
ON_ALL: "on*"
};
JarisFLVPlayer.prototype.isBuffering = function(){
this.setPlayer();
return this.player.api_get("isBuffering");
}
JarisFLVPlayer.prototype.isPlaying = function(){
this.setPlayer();
return this.player.api_get("isPlaying");
}
JarisFLVPlayer.prototype.getCurrentTime = function(){
this.setPlayer();
return this.player.api_get("time");
}
JarisFLVPlayer.prototype.getBytesLoaded = function(){
this.setPlayer();
return this.player.api_get("loaded");
}
JarisFLVPlayer.prototype.getVolume = function(){
this.setPlayer();
return this.player.api_get("volume");
}
JarisFLVPlayer.prototype.addListener = function(event, listener){
this.setPlayer();
this.player.api_addlistener(event, listener);
}
JarisFLVPlayer.prototype.removeListener = function(event){
this.setPlayer();
this.player.api_removelistener(event);
}
JarisFLVPlayer.prototype.play = function(){
this.setPlayer();
this.player.api_play();
}
JarisFLVPlayer.prototype.pause = function(){
this.setPlayer();
this.player.api_pause();
}
JarisFLVPlayer.prototype.seek = function(seconds){
this.setPlayer();
this.player.api_seek(seconds);
}
JarisFLVPlayer.prototype.volume = function(value){
this.setPlayer();
this.player.api_volume(value);
}
JarisFLVPlayer.prototype.loadVideo = function(url,type,streamType,server){
this.setPlayer();
this.player.api_loadVideo(url,type,streamType,server);
}
JarisFLVPlayer.prototype.setPlayer = function(){
this.player = document.getElementById(this.playerId);
}
v2.0.17~dfsg/bin/poster.png 0000644 0000000 0000000 00000256041 12625374554 014350 0 ustar root root PNG
IHDR J"/ sRGB bKGD pHYs tIME-/ IDATx]wJҬUd>77g۽m*3
A}YE9-$@T 3+qI(+^5=?WYkWTvf"AA4{ݛEI $M#.;FnߛfQ@ I$IE5AZjSթva&@?$ YX
Z-OEyZ%I$I
KD3D1Z1#Fo(jS-`h$D R;I$IXJ BncJ'1g[Ƒ+$ 4$I$AJ-6U+D1veFIEWTkq(3AFJb25$I$"X9
z i"lB٫{mI`/~! yN%I$I
Kq2BSHҶ4'!,k)i,-PƐa$I$I.W`A@,>XZC=!hWثQ% HGYXI$IҴ$ ɛ7ܛk