Frame 1
TemplateMini.main(this);
Symbol 20480 MovieClip [__Packages.ATemplate] Frame 0
class ATemplate
{
var _swfWidth, _swfHeight, _shortcuts, _player, controller;
function ATemplate () {
_initFlash();
_initVars();
_initKey();
_initVideo();
_initPlayer();
}
function _initFlash() {
Stage.scaleMode = "noScale";
Stage.align = "TL";
if (_root.width != undefined) {
_swfWidth = Number(_root.width);
} else {
_swfWidth = Stage.width;
}
if (_swfWidth < SWF_MINWIDTH) {
_swfWidth = SWF_MINWIDTH;
}
if (_root.height != undefined) {
_swfHeight = Number(_root.height);
} else {
_swfHeight = Stage.height;
}
if (_swfHeight < SWF_MINHEIGHT) {
_swfHeight = SWF_MINHEIGHT;
}
}
function _initVars() {
}
function _initKey() {
_shortcuts = new Array();
var _local2 = new Object();
_local2.onKeyUp = delegate(this, function () {
if (this._shortcuts[Key.getCode()]) {
this._shortcuts[Key.getCode()]();
}
});
Key.addListener(_local2);
}
function _addShortcut(pKeyCode, pFunction) {
_shortcuts[pKeyCode] = pFunction;
}
function _initVideo() {
video.beginFill(0);
video.lineTo(0, _swfHeight);
video.lineTo(_swfWidth, _swfHeight);
video.lineTo(_swfWidth, 0);
video.endFill();
video.video._width = _swfWidth;
video.video._height = _swfHeight;
video.video._x = 0;
video.video._y = 0;
}
function _initPlayer() {
_player = _root.createEmptyMovieClip("player_mc", _root.getNextHighestDepth());
}
function delegate(pTarget, pFunc) {
var _local4 = function () {
var _local2 = arguments.callee.target;
var _local3 = arguments.callee.func;
return(_local3.apply(_local2));
};
_local4.target = pTarget;
_local4.func = pFunc;
return(_local4);
}
function resizeVideo(pWidth, pHeight) {
var _local4 = ((!(pWidth === undefined)) ? (pWidth) : (video.video.width));
var _local5 = ((!(pHeight === undefined)) ? (pHeight) : (video.video.height));
var _local6 = _swfWidth;
var _local7 = (_local6 * _local5) / _local4;
if (_local7 > _swfHeight) {
_local7 = _swfHeight;
_local6 = (_local7 * _local4) / _local5;
}
video.video._width = _local6;
video.video._height = _local7;
video.video._x = (_swfWidth - _local6) / 2;
video.video._y = (_swfHeight - _local7) / 2;
}
function playRelease() {
controller.play();
if (controller.getLoading().percent != 100) {
startLoading();
}
resizeVideo();
}
function pauseRelease() {
controller.pause();
}
function stopRelease() {
controller.stop();
}
function startLoading() {
}
//ASSetPropFlags(_local1, null, 1);
static var SWF_MINWIDTH = 160;
static var SWF_MINHEIGHT = 120;
var _background = _root.background_mc;
var video = _root.video_mc;
}
Symbol 20481 MovieClip [__Packages.PlayerBasic] Frame 0
class PlayerBasic
{
var _template, _videoUrl, _nc, _ns, _sound, _videoDuration, _times, _positions;
function PlayerBasic (pTemplate) {
_template = pTemplate;
_template.controller = this;
_initVars();
_initVideo();
if (_root.phpstream == "1") {
_isPhpStream = true;
}
if (_root.autoplay == "1") {
_template.playRelease();
} else {
if (_root.autoload == "1") {
_template.playRelease();
}
_template.stopRelease();
}
}
function _initVars() {
if (_root.flv != undefined) {
_videoUrl = _root.flv;
}
if (_root.buffer != undefined) {
_bufferTime = Number(_root.buffer);
}
if (_root.loop == "1") {
_loop = true;
}
}
function _initVideo() {
_nc = new NetConnection();
_nc.connect(null);
_ns = new NetStream(_nc);
_ns.setBufferTime(_bufferTime);
_ns.parent = this;
_ns.onStatus = function (info) {
switch (info.code) {
case "NetStream.Buffer.Empty" :
if (Math.abs(Math.floor(this.time) - Math.floor(this.parent._videoDuration)) < 2) {
this.parent._template.stopRelease();
if (this.parent._loop) {
this.parent._template.playRelease();
}
}
break;
case "NetStream.Buffer.Full" :
this.parent._template.resizeVideo();
}
};
_ns.onMetaData = function (info) {
this.parent._videoDuration = ((info.duration < 0) ? 0 : (info.duration));
this.parent._template.resizeVideo(info.width, info.height);
this.parent._times = info.keyframes.times;
this.parent._positions = info.keyframes.filepositions;
};
_template.video.video.attachVideo(_ns);
_template.video.video.smoothing = true;
_sound = new Sound();
_sound.attachSound(_template.video.video);
}
function play() {
if ((!_nc) && (!_ns)) {
_firstPlay = false;
_initVideo();
}
if (!_firstPlay) {
_ns.play(_videoUrl);
_firstPlay = true;
} else {
_ns.pause();
}
isPlaying = true;
}
function pause() {
_ns.pause();
isPlaying = false;
}
function stop() {
if (_isPhpStream) {
_ns.play(_videoUrl + "0");
_ns.seek(0);
_ns.pause();
} else {
_ns.seek(0);
if (isPlaying) {
_ns.pause();
}
}
isPlaying = false;
if (_root.loadonstop == 0) {
delete _ns;
delete _nc;
}
}
function setPosition(pPosition) {
if (pPosition < 0) {
pPosition = 0;
}
if (pPosition > _videoDuration) {
pPosition = _videoDuration;
}
if (_isPhpStream) {
var _local3 = 0;
var _local4 = _times.length;
if (pPosition <= _times[0]) {
_local3 = _positions[0];
} else if (pPosition >= _times[_local4 - 1]) {
_local3 = _positions[0];
} else {
var _local5 = 40;
var _local6 = 0;
var _local7 = _local4;
var _local8 = 0;
var _local9 = 0;
while ((_local7 - _local6) > _local5) {
var _local10 = _local7 - _local6;
var _local11 = _local10 >> 1;
_local11 = _local6 + _local11;
var _local12 = _times[_local11];
_local8 = _local6;
_local9 = _local11;
if (pPosition >= _local12) {
_local8 = _local11;
_local9 = _local7;
}
_local6 = _local8;
_local7 = _local9;
}
var _local13 = _local6;
for ( ; _local13 < _local7 ; _local13++) {
if ((_times[_local13] <= pPosition) && (pPosition < _times[_local13 + 1])) {
_local3 = _positions[_local13];
break;
}
}
}
_local3 = ((_local3 < 0) ? 0 : (_local3));
_ns.play(_videoUrl + _local3);
if (!isPlaying) {
_ns.pause();
}
} else {
_ns.seek(pPosition);
}
}
function getPosition() {
if (_ns.time > _videoDuration) {
return(_videoDuration);
}
if (_ns.time < 0) {
return(0);
}
if (_ns.time > _videoDuration) {
return(_videoDuration);
}
return(_ns.time);
}
function getDuration() {
return(_videoDuration);
}
function getBufferLength() {
return(_ns.bufferLength);
}
function getBufferTime() {
return(_ns.bufferTime);
}
function getLoading() {
var _local2 = _ns.bytesLoaded;
var _local3 = _ns.bytesTotal;
var _local4 = Math.round((_local2 / _local3) * 100);
return({loaded:_local2, total:_local3, percent:_local4});
}
//ASSetPropFlags(_local1, null, 1);
var _bufferTime = 5;
var _loop = false;
var _isPhpStream = false;
var _firstPlay = false;
var isPlaying = false;
}
Symbol 20482 MovieClip [__Packages.TemplateMini] Frame 0
#initclip
if (!TemplateMini) {
//(_global.TemplateMini = function () {
super();
}) extends ATemplate
var _local1 = (_global.TemplateMini /* register */).prototype;
(_global.TemplateMini /* register */).main = function () {
var _local2 = new PlayerBasic(new TemplateMini());
};
_local1._initKey = function () {
super._initKey();
this._addShortcut(80, this.delegate(this, function () {
if (this.controller.isPlaying) {
this.pauseRelease();
} else {
this.playRelease();
}
}));
this._addShortcut(83, this.delegate(this, function () {
this.stopRelease();
}));
this._addShortcut(37, this.delegate(this, function () {
this.controller.setPosition(this.controller.getPosition() - 5);
}));
this._addShortcut(39, this.delegate(this, function () {
this.controller.setPosition(this.controller.getPosition() + 5);
}));
};
_local1._initVars = function () {
super._initVars();
if (_root.playercolor != undefined) {
this._playerColor = _global.parseInt(_root.playercolor, 16);
}
if (_root.buttoncolor != undefined) {
this._buttonColor = _global.parseInt(_root.buttoncolor, 16);
}
if (_root.slidercolor != undefined) {
this._sliderColor = _global.parseInt(_root.slidercolor, 16);
}
if (_root.loadingcolor != undefined) {
this._loadingColor = _global.parseInt(_root.loadingcolor, 16);
}
};
_local1._initVideo = function () {
super._initVideo();
if (this.video.video._height > (this._swfHeight - TemplateMini.PLAYER_HEIGHT)) {
var _local3 = this.video.video._width / this.video.video._height;
this.video.video._height = this._swfHeight - TemplateMini.PLAYER_HEIGHT;
this.video.video._width = this.video.video._height * _local3;
}
this.video.video._x = (this._swfWidth - this.video.video._width) / 2;
this.video.video._y = ((this._swfHeight - TemplateMini.PLAYER_HEIGHT) - this.video.video._height) / 2;
this._initBuffering();
};
_local1._initBuffering = function () {
this._buffering = this.video.createEmptyMovieClip("buffering_mc", this.video.getNextHighestDepth());
this._buffering.createTextField("message_txt", this._buffering.getNextHighestDepth(), 0, 0, 0, 0);
this._buffering.message_txt.selectable = false;
this._buffering.message_txt.textColor = 16777215 /* 0xFFFFFF */;
this._buffering.message_txt.background = true;
this._buffering.message_txt.backgroundColor = 0;
this._buffering.message_txt.text = "buffering ...";
this._buffering.message_txt.autoSize = "left";
this._buffering._visible = false;
};
_local1._initPlayer = function () {
super._initPlayer();
this._player._y = this._swfHeight - TemplateMini.PLAYER_HEIGHT;
this._initPlayerBackground();
this._initPlayerPlay();
this._initPlayerPause();
this._initPlayerSlider(TemplateMini.BUTTON_WIDTH);
};
_local1._initPlayerBackground = function () {
this._playerBackground = this._player.createEmptyMovieClip("background_mc", this._player.getNextHighestDepth());
this._playerBackground.beginFill(this._playerColor);
this._playerBackground.lineTo(0, TemplateMini.PLAYER_HEIGHT);
this._playerBackground.lineTo(this.video._width, TemplateMini.PLAYER_HEIGHT);
this._playerBackground.lineTo(this.video._width, 0);
this._playerBackground.endFill();
};
_local1._initButton = function (pTarget) {
var _local3 = pTarget.createEmptyMovieClip("area_mc", pTarget.getNextHighestDepth());
var _local4 = pTarget.createEmptyMovieClip("icon_mc", pTarget.getNextHighestDepth());
_local3.beginFill(0, 0);
_local3.moveTo(2, 2);
_local3.lineTo(2, TemplateMini.PLAYER_HEIGHT - 4);
_local3.lineTo(TemplateMini.BUTTON_WIDTH - 4, TemplateMini.PLAYER_HEIGHT - 4);
_local3.lineTo(TemplateMini.BUTTON_WIDTH - 4, 2);
_local3.endFill();
_local3.icon = _local4;
_local3.onRollOver = function () {
this.icon._alpha = 75;
};
_local3.onRollOut = (_local3.onDragOut = (_local3.onPress = function () {
this.icon._alpha = 100;
}));
};
_local1._enableButton = function (pButton, pStatus, pMask) {
pButton.area_mc.enabled = pStatus;
pButton._visible = !pMask;
if (!pStatus) {
pButton.icon_mc._alpha = 30;
} else {
pButton.icon_mc._alpha = 100;
}
};
_local1._initPlayerPlay = function () {
this._playerPlay = this._player.createEmptyMovieClip("play_btn", this._player.getNextHighestDepth());
this._initButton(this._playerPlay);
this._playerPlay.area_mc.onRelease = this.delegate(this, this.playRelease);
this._playerPlay.icon_mc.beginFill(this._buttonColor);
this._playerPlay.icon_mc.lineTo(0, 8);
this._playerPlay.icon_mc.lineTo(6, 4);
this._playerPlay.icon_mc.endFill();
this._playerPlay.icon_mc._y = (TemplateMini.PLAYER_HEIGHT / 2) - (this._playerPlay.icon_mc._height / 2);
this._playerPlay.icon_mc._x = (TemplateMini.BUTTON_WIDTH / 2) - (this._playerPlay.icon_mc._width / 2);
};
_local1._initPlayerPause = function () {
this._playerPause = this._player.createEmptyMovieClip("pause_btn", this._player.getNextHighestDepth());
this._initButton(this._playerPause);
this._playerPause.area_mc.onRelease = this.delegate(this, this.pauseRelease);
this._playerPause.icon_mc.beginFill(this._buttonColor);
this._playerPause.icon_mc.lineTo(0, 8);
this._playerPause.icon_mc.lineTo(3, 8);
this._playerPause.icon_mc.lineTo(3, 0);
this._playerPause.icon_mc.endFill();
this._playerPause.icon_mc.beginFill(this._buttonColor);
this._playerPause.icon_mc.moveTo(5, 0);
this._playerPause.icon_mc.lineTo(5, 8);
this._playerPause.icon_mc.lineTo(8, 8);
this._playerPause.icon_mc.lineTo(8, 0);
this._playerPause.icon_mc.endFill();
this._playerPause.icon_mc._y = (TemplateMini.PLAYER_HEIGHT / 2) - (this._playerPause.icon_mc._height / 2);
this._playerPause.icon_mc._x = (TemplateMini.BUTTON_WIDTH / 2) - (this._playerPause.icon_mc._width / 2);
};
_local1._initPlayerSlider = function (pMargin) {
this._playerSlider = this._player.createEmptyMovieClip("slider_mc", this._player.getNextHighestDepth());
var _local3 = pMargin;
_local3 = _local3 + 10;
this._playerSlider._x = _local3;
this._playerSlider.width = (this._swfWidth - _local3) - 10;
var _local4 = this._playerSlider.createEmptyMovieClip("barBg_mc", this._playerSlider.getNextHighestDepth());
_local4.beginFill(13421772, 25);
_local4.moveTo(0, -1);
_local4.lineTo(this._playerSlider.width, -1);
_local4.lineTo(this._playerSlider.width, 2);
_local4.lineTo(0, 2);
_local4.endFill();
_local4._y = TemplateMini.PLAYER_HEIGHT / 2;
this._loadingBar = this._playerSlider.createEmptyMovieClip("loading_mc", this._playerSlider.getNextHighestDepth());
this._loadingBar.beginFill(this._loadingColor, 75);
this._loadingBar.lineTo(this._playerSlider.width, 0);
this._loadingBar.lineTo(this._playerSlider.width, 2);
this._loadingBar.lineTo(0, 2);
this._loadingBar.endFill();
this._loadingBar._y = TemplateMini.PLAYER_HEIGHT / 2;
this._loadingBar._xscale = 0;
this._loadingBar._visible = false;
var _local5 = this._playerSlider.createEmptyMovieClip("bar_mc", this._playerSlider.getNextHighestDepth());
_local5.parent = this;
_local5.margin = _local3;
_local5.width = TemplateMini.SLIDER_WIDTH;
_local5.barWidth = this._playerSlider.width;
_local5.onRollOver = function () {
this._alpha = 75;
};
_local5.onRollOut = function () {
this._alpha = 100;
};
_local5.onPress = this.delegate(this, function () {
this._playerSlider.bar_mc.startDrag(false, 0, this._playerSlider.bar_mc._y, this._playerSlider.width - this._playerSlider.bar_mc._width, this._playerSlider.bar_mc._y);
this._playerSlider.bar_mc.onEnterFrame = this.delegate(this, this._sliderMoving);
});
_local5.onRelease = (_local5.onReleaseOutside = this.delegate(this, function () {
this._playerSlider.bar_mc.stopDrag();
this._playerSlider.bar_mc.onEnterFrame = this.delegate(this, this._sliderEnterFrame);
}));
_local5.beginFill(this._sliderColor);
_local5.lineTo(0, TemplateMini.SLIDER_HEIGHT);
_local5.lineTo(TemplateMini.SLIDER_WIDTH, TemplateMini.SLIDER_HEIGHT);
_local5.lineTo(TemplateMini.SLIDER_WIDTH, 0);
_local5.endFill();
_local5._y = (TemplateMini.PLAYER_HEIGHT / 2) - (TemplateMini.SLIDER_HEIGHT / 2);
_local5.onEnterFrame = this.delegate(this, this._sliderEnterFrame);
};
_local1._sliderEnterFrame = function () {
if (this._loadingBar._visible) {
var _local2 = this._loadingBar._width - TemplateMini.SLIDER_WIDTH;
} else {
var _local2 = this._playerSlider.width - TemplateMini.SLIDER_WIDTH;
}
if (_local2 < 0) {
var _local2 = 0;
} else if (_local2 > this._playerSlider.width) {
var _local2 = this._playerSlider.width;
}
var _local3 = this.controller.getPosition();
var _local4 = Math.round((_local3 / this.controller.getDuration()) * _local2);
if (_global.isNaN(_local4)) {
_local4 = 0;
}
this._playerSlider.bar_mc._x = _local4;
var _local5 = Math.min(Math.round((this.controller.getBufferLength() / this.controller.getBufferTime()) * 100), 100);
if (((this.controller.getDuration() == undefined) && (this.controller.isPlaying && (_local5 != 100))) || ((_local5 != 100) && (this.controller.isPlaying && ((this.controller.getDuration() - this.controller.getPosition()) > this.controller.getBufferTime())))) {
this._buffering.message_txt.text = ("buffering " + _local5) + "%";
if (_local5 >= this._lastBuffer) {
this._buffering._visible = true;
} else {
this._buffering._visible = false;
}
} else {
this._buffering._visible = false;
}
this._lastBuffer = _local5;
};
_local1._sliderMoving = function () {
var _local2 = (this._playerSlider.bar_mc._x / (this._playerSlider.width - TemplateMini.SLIDER_WIDTH)) * this.controller.getDuration();
this.controller.setPosition(_local2);
};
_local1._loading = function () {
var _local2 = this.controller.getLoading();
this._loadingBar._xscale = ((_local2.percent >= 1) ? (_local2.percent) : 0);
if (_local2.percent == 100) {
this._loadingBar._visible = false;
delete this._loadingBar.onEnterFrame;
}
};
_local1.playRelease = function () {
super.playRelease();
this._enableButton(this._playerPlay, false, true);
this._enableButton(this._playerPause, true);
this._enableButton(this._playerStop, true);
};
_local1.pauseRelease = function () {
super.pauseRelease();
this._enableButton(this._playerPause, false, true);
this._enableButton(this._playerPlay, true);
};
_local1.stopRelease = function () {
super.stopRelease();
this._enableButton(this._playerStop, false);
this._enableButton(this._playerPause, false, true);
this._enableButton(this._playerPlay, true);
};
_local1.startLoading = function () {
super.startLoading();
this._loadingBar.onEnterFrame = this.delegate(this, this._loading);
this._loadingBar._visible = true;
};
ASSetPropFlags(_local1, null, 1);
(_global.TemplateMini /* register */).PLAYER_HEIGHT = 20;
(_global.TemplateMini /* register */).PLAYER_TIMEOUT = 1500;
(_global.TemplateMini /* register */).BUTTON_WIDTH = 26;
(_global.TemplateMini /* register */).SLIDER_WIDTH = 20;
(_global.TemplateMini /* register */).SLIDER_HEIGHT = 10;
_local1._playerColor = 1118481 /* 0x111111 */;
_local1._buttonColor = 16777215 /* 0xFFFFFF */;
_local1._sliderColor = 13421772 /* 0xCCCCCC */;
_local1._loadingColor = 16776960 /* 0xFFFF00 */;
_local1._lastBuffer = 0;
}
#endinitclip