Skip to content

Commit

Permalink
merge with video-js-swf v4.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lileiseven committed May 10, 2015
2 parents 41410ed + fd1f993 commit 84aec09
Show file tree
Hide file tree
Showing 14 changed files with 452 additions and 358 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ _(none)_

--------------------

## 4.6.1 (2015-04-22)
* @bclwhitaker append END_SEQUENCE properly in data generation mode ([view](https://github.com/videojs/video-js-swf/pull/152))

## 4.6.0 (2015-04-16)
* Add vjs_discontinuity ([view](https://github.com/videojs/video-js-swf/pull/150))
* Don't call resume() on NetstreamPlayStart ([view](https://github.com/videojs/video-js-swf/pull/147))

## 4.5.4 (2015-03-17)
* Improved handling of the paused state, and the loadstart and canplay events ([view](https://github.com/videojs/video-js-swf/pull/139))
* Fixed a potential XSS issue with the swf event callbacks ([view](https://github.com/videojs/video-js-swf/pull/143))
* Prevented pause from firing after eneded ([view](https://github.com/videojs/video-js-swf/pull/144))

## 4.5.3 (2015-01-22)
* Paused should be true before a source has been set by default

## 4.5.2 (2014-12-04)
* Fixed an issue where Flash would crash when switching sources quickly ([view](https://github.com/videojs/video-js-swf/pull/131))

## 4.5.1 (2014-10-15)
* Fixed an issue where changing the source immediately after seeking could cause an error ([view](https://github.com/videojs/video-js-swf/pull/125))
* Added sanitation for all data that might be passed through the external interface ([view](https://github.com/videojs/video-js-swf/pull/127))
Expand Down
26 changes: 15 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ module.exports = function (grunt) {
'git-merge-master': { command: 'git merge master' },
'git-checkout-stable': { command: 'git checkout stable' },
'git-checkout-master': { command: 'git checkout master' },
'git-push-stable': { command: 'git push origin stable' },
'git-push-master': { command: 'git push origin master' },
'git-push-tags': { command: 'git push --tags' }
'git-push-origin-stable': { command: 'git push origin stable' },
'git-push-upstream-stable': { command: 'git push upstream stable' },
'git-push-origin-master': { command: 'git push origin master' },
'git-push-upstream-master': { command: 'git push upstream master' },
'git-push-upstream-tags': { command: 'git push upstream --tags' }
},
prompt: {
release: {
Expand Down Expand Up @@ -246,16 +248,16 @@ module.exports = function (grunt) {
});

/**
* How releases work:
*
* How releases work:
*
* Changes come from pullrequests to master or stable.
* They are tested then pulled into their base branch.
* A change log item is added to "Unreleased".
* In a minor/major release, master is merged into stable
* In a minor/major release, master is merged into stable
* (possibly by way of a release branch if testing more).
*
* Check out stable if not already checked out.
* Run `grunt release:RELEASE_TYPE`
* Run `grunt release:RELEASE_TYPE`
* RELEASE_TYPE = major, minor, or patch
* Does the following:
* Bump version
Expand Down Expand Up @@ -283,12 +285,14 @@ module.exports = function (grunt) {
'dist', // build distribution
'shell:git-add-dist-force', // force add the distribution
'tagrelease', // commit & tag the changes
'shell:git-push-stable', // push changes to stable
'shell:git-push-tags', // push version tag
'shell:git-push-origin-stable', // push changes to your fork
'shell:git-push-upstream-stable', // push changes to upstream
'shell:git-push-upstream-tags', // push version tag
'npm-publish', // publish to npm
'shell:git-checkout-master', // switch to master branch
'shell:git-merge-stable', // merge stable into master
'shell:git-push-master' // push changes to master
'shell:git-push-origin-master', // push changes to your fork
'shell:git-push-upstream-master' // push changes upstream
]);
});

Expand All @@ -300,4 +304,4 @@ module.exports = function (grunt) {
grunt.fatal('Confirmation failed.');
}
});
};
};
Binary file modified dist/video-js.swf
Binary file not shown.
Binary file added dist/video-js.swf.orig
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "videojs-swf",
"description": "The Flash-fallback video player for video.js (http://videojs.com)",
"version": "4.5.1",
"version": "4.6.1",
"copyright": "Copyright 2014 Brightcove, Inc. https://github.com/videojs/video-js-swf/blob/master/LICENSE",
"keywords": [
"flash",
Expand Down
111 changes: 61 additions & 50 deletions src/VideoJS.as
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package{

import com.videojs.VideoJSApp;
import com.videojs.events.VideoJSEvent;
import com.videojs.structs.ExternalEventName;
import com.videojs.structs.ExternalErrorEventName;
import com.videojs.Base64;

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
Expand All @@ -20,21 +20,21 @@ package{
import flash.utils.ByteArray;
import flash.utils.Timer;
import flash.utils.setTimeout;

[SWF(backgroundColor="#000000", frameRate="60", width="480", height="270")]
public class VideoJS extends Sprite{

public const VERSION:String = CONFIG::version;

private var _app:VideoJSApp;
private var _stageSizeTimer:Timer;

public function VideoJS(){
_stageSizeTimer = new Timer(250);
_stageSizeTimer.addEventListener(TimerEvent.TIMER, onStageSizeTimerTick);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}

private function init():void{
// Allow JS calls from other domains
Security.allowDomain("*");
Expand All @@ -44,17 +44,18 @@ package{
// we'll want to suppress ANY uncaught debug errors in production (for the sake of ux)
// IEventDispatcher(loaderInfo["uncaughtErrorEvents"]).addEventListener("uncaughtError", onUncaughtError);
}

if(ExternalInterface.available){
registerExternalMethods();
}

_app = new VideoJSApp();
addChild(_app);

_app.model.stageRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);

// add content-menu version info

var _ctxVersion:ContextMenuItem = new ContextMenuItem("VideoJS Flash Component v" + VERSION, false, false);
var _ctxAbout:ContextMenuItem = new ContextMenuItem("Copyright © 2014 Brightcove, Inc.", false, false);
var _ctxMenu:ContextMenu = new ContextMenu();
Expand All @@ -63,15 +64,15 @@ package{
this.contextMenu = _ctxMenu;

}

private function registerExternalMethods():void{

try{
ExternalInterface.addCallback("vjs_appendBuffer", onAppendBufferCalled);
ExternalInterface.addCallback("vjs_echo", onEchoCalled);
ExternalInterface.addCallback("vjs_endOfStream", onEndOfStreamCalled);
ExternalInterface.addCallback("vjs_abort", onAbortCalled);

ExternalInterface.addCallback("vjs_discontinuity", onDiscontinuityCalled);
ExternalInterface.addCallback("vjs_getProperty", onGetPropertyCalled);
ExternalInterface.addCallback("vjs_setProperty", onSetPropertyCalled);
ExternalInterface.addCallback("vjs_autoplay", onAutoplayCalled);
Expand All @@ -93,13 +94,13 @@ package{
}
}
finally{}



setTimeout(finish, 50);

}

private function finish():void{

// Pass the whole parameters to the model so that any provider may refer it.
Expand All @@ -108,23 +109,26 @@ package{
if(loaderInfo.parameters.mode != undefined){
_app.model.mode = loaderInfo.parameters.mode;
}

if(loaderInfo.parameters.eventProxyFunction != undefined){

// Hard coding these in for now until we can come up with a better solution for 5.0 to avoid XSS.
_app.model.jsEventProxyName = 'videojs.Flash.onEvent';
_app.model.jsErrorEventProxyName = 'videojs.Flash.onError';

/*if(loaderInfo.parameters.eventProxyFunction != undefined){
_app.model.jsEventProxyName = loaderInfo.parameters.eventProxyFunction;
}
if(loaderInfo.parameters.errorEventProxyFunction != undefined){
_app.model.jsErrorEventProxyName = loaderInfo.parameters.errorEventProxyFunction;
}
}*/

if(loaderInfo.parameters.autoplay != undefined && loaderInfo.parameters.autoplay == "true"){
_app.model.autoplay = true;
}

if(loaderInfo.parameters.preload === "none"){
_app.model.preload = false;
}

if(loaderInfo.parameters.poster != undefined && loaderInfo.parameters.poster != ""){
_app.model.poster = String(loaderInfo.parameters.poster);
}
Expand All @@ -145,35 +149,38 @@ package{
_app.model.rtmpStream = loaderInfo.parameters.rtmpStream;
}
}

if(loaderInfo.parameters.readyFunction != undefined){
try{
ExternalInterface.call(_app.model.cleanEIString(loaderInfo.parameters.readyFunction), ExternalInterface.objectID);
}
catch(e:Error){
if (loaderInfo.parameters.debug != undefined && loaderInfo.parameters.debug == "true") {
throw new Error(e.message);
}

// Hard coding this in for now until we can come up with a better solution for 5.0 to avoid XSS.
ExternalInterface.call('videojs.Flash.onReady', ExternalInterface.objectID);

/*if(loaderInfo.parameters.readyFunction != undefined){
try{
ExternalInterface.call(_app.model.cleanEIString(loaderInfo.parameters.readyFunction), ExternalInterface.objectID);
}
catch(e:Error){
if (loaderInfo.parameters.debug != undefined && loaderInfo.parameters.debug == "true") {
throw new Error(e.message);
}
}
}
}*/
}

private function onAddedToStage(e:Event):void{
stage.addEventListener(MouseEvent.CLICK, onStageClick);
stage.addEventListener(Event.RESIZE, onStageResize);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
_stageSizeTimer.start();
}

private function onStageSizeTimerTick(e:TimerEvent):void{
if(stage.stageWidth > 0 && stage.stageHeight > 0){
_stageSizeTimer.stop();
_stageSizeTimer.removeEventListener(TimerEvent.TIMER, onStageSizeTimerTick);
init();
}
}

private function onStageResize(e:Event):void{
if(_app != null){
_app.model.stageRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
Expand All @@ -187,7 +194,7 @@ package{
// write the bytes to the provider
_app.model.appendBuffer(bytes);
}

private function onEchoCalled(pResponse:* = null):*{
return pResponse;
}
Expand All @@ -199,7 +206,11 @@ package{
private function onAbortCalled():*{
_app.model.abort();
}


private function onDiscontinuityCalled():*{
_app.model.discontinuity();
}

private function onGetPropertyCalled(pPropertyName:String = ""):*{

switch(pPropertyName){
Expand All @@ -210,7 +221,7 @@ package{
case "loop":
return _app.model.loop;
case "preload":
return _app.model.preload;
return _app.model.preload;
break;
case "metadata":
return _app.model.metadata;
Expand Down Expand Up @@ -280,7 +291,7 @@ package{
break;
case "rtmpConnection":
return _app.model.rtmpConnectionURL;
break;
break;
case "rtmpStream":
return _app.model.rtmpStream;
break;
Expand All @@ -296,8 +307,8 @@ package{
}
return null;
}
private function onSetPropertyCalled(pPropertyName:String = "", pValue:* = null):void{

private function onSetPropertyCalled(pPropertyName:String = "", pValue:* = null):void{
switch(pPropertyName){
case "duration":
_app.model.duration = Number(pValue);
Expand Down Expand Up @@ -356,7 +367,7 @@ package{
break;
}
}

private function onAutoplayCalled(pAutoplay:* = false):void{
_app.model.autoplay = _app.model.humanToBoolean(pAutoplay);
}
Expand All @@ -374,7 +385,7 @@ package{
}
ExternalInterface.call('videojs.MediaSource.open', cleanSrc, ExternalInterface.objectID);
}

private function onSrcCalled(pSrc:* = ""):void{
// check if an external media source object will provide the video data
if (isExternalMSObjectURL(pSrc)) {
Expand All @@ -389,34 +400,34 @@ package{
_app.model.src = String(pSrc);
}
}

private function onLoadCalled():void{
_app.model.load();
}

private function onPlayCalled():void{
_app.model.play();
}

private function onPauseCalled():void{
_app.model.pause();
}

private function onResumeCalled():void{
_app.model.resume();
}

private function onStopCalled():void{
_app.model.stop();
}

private function onUncaughtError(e:Event):void{
e.preventDefault();
}

private function onStageClick(e:MouseEvent):void{
_app.model.broadcastEventExternally(ExternalEventName.ON_STAGE_CLICK);
}

}
}
Loading

0 comments on commit 84aec09

Please sign in to comment.