Combined Code
frame 1 {
function init_vars() {
this.is_playing = false;
this.is_muted = false;
this.is_seeking = false;
this.first_hover = false;
this.duration_minutes = '0';
this.duration_seconds = '00';
this.controls_override = false;
}
function fn_resize_poster() {
var poster_scale = Math.min(Stage.width / poster_trueWidth, Stage.height / poster_trueHeight);
with (poster_canvas) {
_width = poster_trueWidth * poster_scale;
_height = poster_trueHeight * poster_scale;
_x = (Stage.width - poster_trueWidth * poster_scale) / 2;
_y = (Stage.height - poster_trueHeight * poster_scale) / 2;
}
}
function onMetaData(args) {
fadeOut(poster_canvas, 30);
video_trueWidth = _root.width ? _root.width : (args.width || Stage.width);
video_trueHeight = _root.height ? _root.height : (args.height || Stage.height);
video_duration = args.duration || 0;
duration_minutes = Math.floor(video_duration / 60);
duration_seconds = Math.floor(video_duration - duration_minutes * 60);
duration_seconds = duration_seconds < 10 ? '0' + duration_seconds : duration_seconds;
duration_text_holder.duration_text.text = duration_minutes + ':' + duration_seconds;
duration_text_holder.duration_text.setTextFormat(duration_text_format);
fn_resize_video();
}
function connect() {
this.nc = new NetConnection();
this.nc.connect(null);
this.stream = new NetStream(nc);
this.stream.setBufferTime(10);
this.video.attachVideo(stream);
this.video_canvas.attachAudio(stream);
this.audio = new Sound(video_canvas);
this.audio.setVolume(100);
this.stream.onMetaData = onMetaData;
}
function fn_resize_video() {
var video_scale = Math.min(Stage.width / video_trueWidth, Stage.height / video_trueHeight);
with (video) {
_width = video_trueWidth * video_scale;
_height = video_trueHeight * video_scale;
_x = (Stage.width - video_trueWidth * video_scale) / 2;
_y = (Stage.height - video_trueHeight * video_scale) / 2;
}
}
function fn_draw_controls() {
controls_visible = false;
this.createEmptyMovieClip('controls_bg', 20);
with (controls_bg) {
_alpha = 0;
beginFill(1709847);
moveTo(0, Stage.height - 28);
lineTo(Stage.width, Stage.height - 28);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
endFill();
}
this.createEmptyMovieClip('play_btn', 21);
with (play_btn) {
_alpha = 0;
_x = 9;
_y = Stage.height - 20;
beginFill(16777215);
moveTo(0, 0);
lineTo(9, 6);
lineTo(0, 12);
endFill();
}
this.createEmptyMovieClip('pause_btn', 22);
with (pause_btn) {
_alpha = 0;
_x = 9;
_y = Stage.height - 20;
beginFill(16777215);
moveTo(0, 0);
lineTo(0, 12);
lineTo(4, 12);
lineTo(4, 0);
endFill();
beginFill(16777215);
moveTo(7, 0);
lineTo(7, 12);
lineTo(11, 12);
lineTo(11, 0);
endFill();
}
this.createEmptyMovieClip('duration_bar', 23);
with (duration_bar) {
_alpha = 0;
_x = 32;
_y = Stage.height - 14;
lineStyle(8, 10263194, 80);
moveTo(0, 0);
lineTo(Stage.width - 98 - BTN_FULL_W, 0);
}
this.createEmptyMovieClip('progress_bar', 24);
with (progress_bar) {
_alpha = 0;
_x = 32;
_y = Stage.height - 14;
lineStyle(8, 13289672, 80);
moveTo(0, 0);
lineTo(7, 0);
}
this.createEmptyMovieClip('time_slider', 25);
with (time_slider) {
_alpha = 0;
_x = 28;
_y = Stage.height - 23;
lineStyle(2.5, 16777215, 100);
beginFill(4671303);
moveTo(0, 5);
curveTo(0, 0, 4.5, 0);
curveTo(9, 0, 9, 5);
lineTo(9, 13);
curveTo(9, 18, 4.5, 18);
curveTo(0, 18, 0, 13);
lineTo(0, 5);
endFill();
}
this.createEmptyMovieClip('volume_btn', 26);
with (volume_btn) {
_alpha = 0;
_x = Stage.width - 24 - BTN_FULL_W;
_y = Stage.height - 22;
lineStyle(0, 16777215, 100);
beginFill(16777215);
moveTo(0, 5);
lineTo(0, 10);
lineTo(3, 10);
lineTo(8, 14);
lineTo(8, 1);
lineTo(3, 5);
endFill();
}
this.createEmptyMovieClip('volume_on_btn', 27);
with (volume_on_btn) {
_alpha = 0;
_x = Stage.width - 12 - BTN_FULL_W;
_y = Stage.height - 18;
lineStyle(3, 16777215, 100);
moveTo(0, 0);
curveTo(5, 3, 0, 7);
}
this.createEmptyMovieClip('duration_text_holder', 28);
with (duration_text_holder) {
_alpha = 0;
_x = Stage.width - 56 - BTN_FULL_W;
_y = Stage.height - 23;
}
fullIn._x = Stage.width - BTN_FULL_W;
fullOut._x = fullIn._x;
fullIn._y = Stage.height - BTN_FULL_H;
fullOut._y = fullIn._y;
fullIn.swapDepths(this.getNextHighestDepth());
fullOut.swapDepths(this.getNextHighestDepth());
fullIn._alpha = 0;
fullOut._alpha = 0;
duration_text_holder.createTextField('duration_text', 29, 0, 0, 60, 20);
duration_text_format = new TextFormat();
duration_text_format.color = 13421772;
duration_text_format.font = 'Arial';
duration_text_format.size = '11';
duration_text_holder.duration_text.text = duration_minutes + ':' + duration_seconds;
duration_text_holder.duration_text.setTextFormat(duration_text_format);
this.createEmptyMovieClip('control_canvas', 1000);
control_canvas.buttonMode = false;
with (control_canvas) {
_alpha = 0;
beginFill(0);
moveTo(0, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
endFill();
}
control_canvas.onRollOver = function () {
is_seeking = false;
first_hover = true;
};
control_canvas.onRollOut = function () {
controls_hover_timeout = 24;
is_seeking = false;
};
control_canvas.onPress = function () {
if (_root._ymouse >= Stage.height - 28) {
is_seeking = true;
}
};
control_canvas.onMouseMove = function () {
if (is_seeking) {
stream.seek(((_root._xmouse - 28) / duration_bar._width) * video_duration);
}
if (!controls_visible) {
fn_controls_visible(36);
}
if (_root._ymouse >= Stage.height - 28) {
controls_hover_timeout = 576;
} else {
controls_hover_timeout = 288;
}
};
control_canvas.onRelease = function () {
if (_root._xmouse <= 28 && _root._ymouse >= Stage.height - 28) {
if (!is_playing) {
fn_play();
} else {
fn_pause();
}
} else {
if (_root._xmouse >= Stage.width - 28 - BTN_FULL_W && _root._xmouse <= Stage.width - 4 - BTN_FULL_W && _root._ymouse >= Stage.height - 28) {
if (!is_muted) {
fn_mute();
} else {
fn_unmute();
}
} else {
if (fullScreenEnabled && _root._xmouse >= Stage.width - BTN_FULL_W && _root._xmouse <= Stage.width - 4 && _root._ymouse >= Stage.height - BTN_FULL_H) {
if (Stage.displayState == 'normal') {
fn_fullscreen();
} else {
fn_fullscreen_off();
}
} else {
if (is_seeking) {
stream.seek(((_root._xmouse - 28) / duration_bar._width) * video_duration);
}
}
}
}
is_seeking = false;
};
control_canvas.onReleaseOutside = function () {
is_seeking = false;
};
}
function fn_time() {
time_slider._x = duration_bar._width * (video_position / video_duration) + 28;
}
function fn_progress() {
progress_bar.lineTo((duration_bar._width - 8) * (video_percent / 100), 0);
}
function fadeIn(mc, fadeRate, toAlpha) {
toAlpha = toAlpha || 100;
fadeRate = fadeRate || 20;
mc.onEnterFrame = null;
mc.onEnterFrame = function () {
if (this._alpha >= toAlpha) {
this._alpha = toAlpha;
this.onEnterFrame = null;
} else {
this._alpha += fadeRate;
this._alpha = Math.min(this._alpha, toAlpha);
}
};
}
function fadeOut(mc, fadeRate, toAlpha) {
toAlpha = toAlpha || 0;
fadeRate = fadeRate || 20;
mc.onEnterFrame = null;
mc.onEnterFrame = function () {
if (this._alpha <= toAlpha) {
this._alpha = toAlpha;
this.onEnterFrame = null;
} else {
this._alpha -= Math.max(toAlpha - this._alpha - fadeRate, fadeRate, toAlpha);
}
};
}
function fn_controls_visible(fadeRate) {
if (!controls_override && controls_locked) {
return undefined;
}
controls_visible = true;
fadeRate = fadeRate || 100;
fadeIn(controls_bg, fadeRate, 70);
if (is_playing) {
fadeIn(pause_btn, fadeRate);
play_btn._alpha = 0;
} else {
fadeIn(play_btn, fadeRate);
pause_btn._alpha = 0;
}
fadeIn(duration_bar, fadeRate);
fadeIn(progress_bar, fadeRate);
fadeIn(time_slider, fadeRate);
setTimeout(function () {
duration_text_holder._alpha = 100;
}, fadeRate);
fadeIn(volume_btn, fadeRate);
if (!is_muted) {
fadeIn(volume_on_btn, fadeRate);
} else {
volume_on_btn._alpha = 0;
}
if (Stage.displayState == 'fullScreen') {
fadeIn(fullIn, fadeRate);
fullOut._alpha = 0;
} else {
fullIn._alpha = 0;
fadeIn(fullOut, fadeRate);
}
}
function fn_controls_hidden(fadeRate) {
controls_visible = false;
fadeRate = fadeRate || 100;
fadeOut(controls_bg, fadeRate);
fadeOut(play_btn, fadeRate);
fadeOut(pause_btn, fadeRate);
fadeOut(duration_bar, fadeRate);
fadeOut(progress_bar, fadeRate);
fadeOut(time_slider, fadeRate);
setTimeout(function () {
duration_text_holder._alpha = 0;
}, fadeRate);
fadeOut(duration_text, fadeRate);
fadeOut(volume_btn, fadeRate);
fadeOut(volume_on_btn, fadeRate);
fadeOut(fullIn, fadeRate);
fadeOut(fullOut, fadeRate);
}
function fn_play() {
onPlayedChecked = false;
if (!isStoped && stream.bytesLoaded && video_position != video_duration) {
stream.pause();
} else {
if (isStoped) {
init_vars();
connect();
}
stream.play(_root.src);
}
is_playing = true;
isStoped = false;
if (controls_visible) {
fn_controls_hidden(10);
fn_controls_visible(40);
} else {
fn_controls_visible(10);
fn_controls_hidden(40);
}
rightClick.customItems.splice(0, 1, cmi_pause);
}
function fn_pause() {
is_playing = false;
stream.pause();
video_position = stream.time;
fn_controls_visible();
rightClick.customItems.splice(0, 1, cmi_play);
}
function fn_mute() {
is_muted = true;
audio.setVolume(0);
fn_controls_visible();
rightClick.customItems.splice(1, 1, cmi_unmute);
}
function fn_unmute() {
is_muted = false;
audio.setVolume(100);
fn_controls_visible();
rightClick.customItems.splice(1, 1, cmi_mute);
}
function fn_showcontrols() {
rightClick.customItems.splice(2, 1, cmi_hidecontrols);
controls_locked = false;
fn_controls_visible();
}
function fn_hidecontrols() {
rightClick.customItems.splice(2, 1, cmi_showcontrols);
fn_controls_hidden();
controls_locked = true;
}
function fn_fullscreen() {
Stage.displayState = 'fullScreen';
}
function fn_fullscreen_off() {
Stage.displayState = 'normal';
}
function display_init() {
fn_draw_controls();
fn_controls_visible();
fn_resize_poster();
fn_resize_video();
}
function onPlayed() {
if (onPlayedChecked) {
return undefined;
}
if (video_duration != undefined && stream.time + 0.4 >= video_duration) {
onPlayedChecked = true;
is_playing = false;
isStoped = true;
setTimeout(function () {
if (loop) {
fn_play();
} else {
video.clear();
if (posterOnEnd) {
fadeIn(poster_canvas, 30);
}
}
}, 200);
}
}
function jsInAs() {
fn_play();
}
Stage.align = 'LT';
Stage.scaleMode = 'noScale';
var connect;
var stream;
var video;
var audio;
var poster_trueWidth;
var poster_trueHeight;
var video_trueWidth;
var video_trueHeight;
var video_position;
var video_percent;
var video_duration;
var is_playing = false;
var is_muted = false;
var is_seeking = false;
var first_hover = false;
var posterOnEnd = _root.posterOnEnd == 'true';
var fullScreenEnabled = _root.fullScreenEnabled == 'true';
var loop = _root.loop == 'true';
var autoplay = _root.autoplay == 'true';
var controls_locked = _root.controls == 'false';
var controls_visible = _root.controls == 'true';
var controls_hover_timeout = 192;
var controls_override = false;
var duration_text_format;
var duration_minutes = '0';
var duration_seconds = '00';
var fullscreen = new Object();
var keyboard = new Object();
var BTN_FULL_W = fullScreenEnabled ? 24 : 0;
var BTN_FULL_H = 22;
fullOut._visible = false;
fullIn._visible = fullOut._visible;
init_vars();
this.createEmptyMovieClip('poster_canvas', 0);
var poster_mclListener = new Object();
poster_mclListener.onLoadInit = function (target_mc) {
poster_trueWidth = _root.width ? _root.width : (poster_canvas._width || Stage.width);
poster_trueHeight = _root.height ? _root.height : (poster_canvas._height || Stage.height);
fn_resize_poster();
};
var poster_mcl = new MovieClipLoader();
poster_mcl.addListener(poster_mclListener);
poster_mcl.loadClip(_root.poster, poster_canvas);
this.createEmptyMovieClip('video_canvas', 300);
connect();
var isStoped = false;
Stage.addListener(fullscreen);
fullscreen.onFullScreen = function () {
if (Stage.displayState == 'normal') {
controls_override = false;
_root.menu = rightClick;
}
if (Stage.displayState == 'fullScreen') {
controls_override = true;
_root.menu = rightClickBlank;
}
fn_controls_visible();
display_init();
controls_hover_timeout = 480;
};
Key.addListener(keyboard);
keyboard.onKeyDown = function () {
if (Key.isDown(32)) {
if (!is_playing) {
fn_play();
} else {
fn_pause();
}
}
if (Key.isDown(17) && Key.isDown(37)) {
stream.seek(Math.max(0, stream.time - stream.duration / 10));
controls_hover_timeout = 288;
} else {
if (Key.isDown(17) && Key.isDown(39)) {
stream.seek(Math.min(video_duration, stream.time + stream.duration / 10));
controls_hover_timeout = 288;
} else {
if (Key.isDown(17) && Key.isDown(38)) {
if (is_muted) {
fn_unmute();
}
controls_hover_timeout = 288;
} else {
if (Key.isDown(17) && Key.isDown(40)) {
if (!is_muted) {
fn_mute();
}
controls_hover_timeout = 288;
} else {
if (Key.isDown(37)) {
stream.seek(Math.max(0, stream.time - 15));
controls_hover_timeout = 288;
} else {
if (Key.isDown(39)) {
stream.seek(Math.min(video_duration, stream.time + 15));
controls_hover_timeout = 288;
}
}
}
}
}
}
};
var rightClick = new ContextMenu();
rightClick.hideBuiltInItems();
var rightClickBlank = new ContextMenu();
rightClickBlank.hideBuiltInItems();
var cmi_play = new ContextMenuItem('&Play ', fn_play);
var cmi_pause = new ContextMenuItem('&Pause ', fn_pause);
var cmi_mute = new ContextMenuItem('&Mute ', fn_mute);
var cmi_unmute = new ContextMenuItem('Un&mute ', fn_unmute);
var cmi_hidecontrols = new ContextMenuItem('Hide &Controls ', fn_hidecontrols);
var cmi_showcontrols = new ContextMenuItem('Show &Controls ', fn_showcontrols);
var cmi_fullscreen = fullScreenEnabled ? new ContextMenuItem('&Full Screen ', fn_fullscreen) : null;
var onPlayedChecked = false;
var checkId = setInterval(function () {
if (stream) {
if (stream.bytesLoaded && stream.bytesTotal) {
video_percent = (stream.bytesLoaded / stream.bytesTotal) * 100;
}
video_position = stream.time;
onPlayed();
}
if (controls_visible && controls_hover_timeout <= 0 && first_hover) {
fn_controls_hidden(15);
} else {
if (controls_visible) {
--controls_hover_timeout;
}
}
fn_time();
fn_progress();
}, 9);
setTimeout(function () {
display_init();
duration_text_holder._visible = false;
fn_controls_hidden(10);
setTimeout(function () {
duration_text_holder._visible = true;
fullOut._visible = fullScreenEnabled;
fullIn._visible = fullOut._visible;
}, 350);
setTimeout(function () {
if (autoplay) {
fn_play();
}
}, 100);
}, 100);
if (controls_locked) {
rightClick.customItems.push(cmi_play, cmi_mute, cmi_showcontrols, cmi_fullscreen);
} else {
rightClick.customItems.push(cmi_play, cmi_mute, cmi_hidecontrols, cmi_fullscreen);
}
_root.menu = rightClick;
ExternalInterface.addCallback('jsToAs', this, jsInAs);
}
movieClip 4 {
}
movieClip 7 {
}