Skip to content

Instantly share code, notes, and snippets.

@aaronk6
Created Sep 25, 2014
Embed
What would you like to do?
ActionScript 3 source from https://github.com/sproutcore/sproutcore/blob/master/frameworks/media/resources/playeras3.fla (rev c9bf4139f7b29ff3394df0c6651c432cd9dfa235)
import flash.external.ExternalInterface;
import fl.video.*;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var scid= String(paramObj['scid']);
if(String(paramObj['src']).length>1) videoCanvas.source = String(paramObj['src']);
else videoCanvas.source = 'http://localhost:4020/static/video/en/current/video.m4v';
videoCanvas.addEventListener(VideoEvent.READY, ready);
videoCanvas.addEventListener(VideoEvent.AUTO_REWOUND, autoRewound);
videoCanvas.addEventListener(VideoEvent.BUFFERING_STATE_ENTERED, bufferingStateEntered);
videoCanvas.addEventListener(VideoEvent.CLOSE, close);
videoCanvas.addEventListener(VideoEvent.COMPLETE, complete);
videoCanvas.addEventListener(VideoEvent.FAST_FORWARD, fastForward);
videoCanvas.addEventListener(VideoEvent.PAUSED_STATE_ENTERED, pauseStateEntered);
videoCanvas.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, playingStateEntered);
videoCanvas.addEventListener(VideoEvent.PLAYHEAD_UPDATE, playheadUpdate);
videoCanvas.addEventListener(VideoProgressEvent.PROGRESS, progress);
videoCanvas.addEventListener(VideoEvent.REWIND, rewind);
videoCanvas.addEventListener(VideoEvent.SCRUB_FINISH, scrubFinish);
videoCanvas.addEventListener(VideoEvent.SCRUB_START, scrubStart);
videoCanvas.addEventListener(VideoEvent.SEEKED, seeked);
videoCanvas.addEventListener(VideoEvent.STATE_CHANGE, stateChanged);
videoCanvas.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, stoppedStateEntered);
videoCanvas.addEventListener(MetadataEvent.METADATA_RECEIVED, metadataReceived);
//addChild(videoCanvas);
function ready(e:VideoEvent):void{
//ExternalInterface.call ("alert", scid);
}
function metadataReceived(e:MetadataEvent):void {
ExternalInterface.call ("SC.VideoView.updateProperty", scid, "videoHeight", e.info.height);
ExternalInterface.call ("SC.VideoView.updateProperty", scid, "videoWidth", e.info.width);
ExternalInterface.call ("SC.VideoView.updateProperty", scid, "duration", e.info.duration);
ExternalInterface.call ("SC.VideoView.updateProperty", scid, "volume", videoCanvas.volume);
};
function playheadUpdate(e:VideoEvent):void {
ExternalInterface.call ("SC.VideoView.updateProperty", scid, "currentTime", videoCanvas.playheadTime);
};
function autoRewound(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "autorewing Event"); trace("autorewing Event"); }
function bufferingStateEntered(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "buffering Event"); trace("buffering Event"); }
function close(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "close Event"); trace("close Event"); }
function complete(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "complete Event"); trace("complete Event"); }
function fastForward(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "fastForward Event"); trace("fastForward Event"); }
function pauseStateEntered(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "pauseState Event"); trace("pauseState Event"); }
function playingStateEntered(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "playingState Event"); trace("playingState Event"); }
function progress(e:VideoProgressEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "progress Event"); trace("progress Event"); }
function rewind(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "rewing Event"); trace("rewing Event"); }
function scrubFinish(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "scrubFinish Event"); trace("scrubFinish Event"); }
function scrubStart(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "scrubStart Event"); trace("scrubStart Event"); }
function seeked(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "seeked Event"); trace("seeked Event"); }
function stateChanged(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "stateChanged Event"); trace("stateChanged Event"); }
function stoppedStateEntered(e:VideoEvent):void { ExternalInterface.call ("SC.VideoView.logFlash", "stoppedState Event"); trace("stoppedState Event"); }
function playVideoCall(){
videoCanvas.play();
};
function pauseVideoCall(){
videoCanvas.stop();
};
function setVolumeVideoCall(vol:Number){
videoCanvas.volume=vol;
};
function setTimeVideoCall(time:Number){
seekTime.text = String(time);
videoCanvas.seek(time);
};
function fullScreenVideoCall(time:Number){
try{
videoCanvas.enterFullScreenDisplayState();
}catch(e){
ExternalInterface.call ("alert", e);
}
};
// Callback function executed by the name of variable
ExternalInterface.addCallback("playVideo", playVideoCall);
ExternalInterface.addCallback("pauseVideo", pauseVideoCall);
ExternalInterface.addCallback("setVolume", setVolumeVideoCall);
ExternalInterface.addCallback("setTime", setTimeVideoCall);
ExternalInterface.addCallback("fullScreen", fullScreenVideoCall);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment