Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mangui committed Oct 24, 2014
1 parent 06441aa commit e8b78be
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 30 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ _(none)_

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

## 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))

## 4.5.0 (2014-09-29)
* Buffering and playback event fixes ([view](https://github.com/videojs/video-js-swf/pull/122))

## 4.4.5 (2014-09-25)
* Fixed sanitation of URLs to special case blob URLs ([view](https://github.com/videojs/video-js-swf/pull/121))

## 4.4.4 (2014-09-22)
* Added sanitizing of the src param ([view](https://github.com/videojs/video-js-swf/pull/120))

## 4.4.3 (2014-08-14)
* Rebuild with Flash target-player 10.3 and swf-version 12. ([view](https://github.com/videojs/video-js-swf/issues/113))

## 4.4.2 (2014-07-11)
* Fixed networkState reporting to be more accurate after loadstart ([view](https://github.com/videojs/video-js-swf/pull/106))

Expand Down
Binary file modified dist/video-js.swf
Binary file not shown.
4 changes: 2 additions & 2 deletions 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.4.2",
"version": "4.5.1",
"copyright": "Copyright 2014 Brightcove, Inc. https://github.com/videojs/video-js-swf/blob/master/LICENSE",
"keywords": [
"flash",
Expand All @@ -17,7 +17,7 @@
"devDependencies": {
"async": "~0.2.9",
"flex-sdk": "4.6.0-0",
"video.js": "^4.6.0",
"video.js": "^4.9.0",
"grunt-cli": "~0.1.0",
"grunt": "~0.4.0",
"grunt-connect": "~0.2.0",
Expand Down
14 changes: 11 additions & 3 deletions src/VideoJS.as
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ package{
_app.model.autoplay = true;
}

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

if(loaderInfo.parameters.poster != undefined && loaderInfo.parameters.poster != ""){
Expand Down Expand Up @@ -318,6 +318,8 @@ package{
case "errorEventProxyFunction":
_app.model.jsErrorEventProxyName = String(pValue);
break;
case "autoplay":
_app.model.autoplay = _app.model.humanToBoolean(pValue);
case "preload":
_app.model.preload = _app.model.humanToBoolean(pValue);
break;
Expand Down Expand Up @@ -364,7 +366,13 @@ package{
}

private function openExternalMSObject(pSrc:*):void{
ExternalInterface.call('videojs.MediaSource.open', pSrc, ExternalInterface.objectID);
var cleanSrc:String
if (/^blob:vjs-media-source\/\d+$/.test(pSrc)) {
cleanSrc = pSrc;
} else {
cleanSrc = _app.model.cleanEIString(pSrc);
}
ExternalInterface.call('videojs.MediaSource.open', cleanSrc, ExternalInterface.objectID);
}

private function onSrcCalled(pSrc:* = ""):void{
Expand Down
51 changes: 40 additions & 11 deletions src/com/videojs/VideoJSModel.as
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ package com.videojs{
private var _backgroundAlpha:Number = 0;
private var _volume:Number = 1;
private var _autoplay:Boolean = false;
private var _preload:Boolean = false;
private var _preload:Boolean = true;
private var _loop:Boolean = false;
private var _src:String = "";
private var _rtmpConnectionURL:String = "";
Expand Down Expand Up @@ -454,7 +454,8 @@ package com.videojs{
if(ExternalInterface.available){
var __incomingArgs:* = args as Array;
var __newArgs:Array = [_jsEventProxyName, ExternalInterface.objectID].concat(__incomingArgs);
ExternalInterface.call.apply(null, __newArgs);
var __sanitizedArgs:Array = cleanObject(__newArgs);
ExternalInterface.call.apply(null, __sanitizedArgs);
}
}
}
Expand All @@ -469,6 +470,7 @@ package com.videojs{
if(ExternalInterface.available){
var __incomingArgs:* = args as Array;
var __newArgs:Array = [_jsErrorEventProxyName, ExternalInterface.objectID].concat(__incomingArgs);
var __sanitizedArgs:Array = cleanObject(__newArgs);
ExternalInterface.call.apply(null, __newArgs);
}
}
Expand Down Expand Up @@ -611,15 +613,42 @@ package com.videojs{
return false;
}
}

/**
* Removes dangerous characters from a user-provided string that will be passed to ExternalInterface.call()
*
*/
public function cleanEIString(pString:String):String{
return pString.replace(/[^A-Za-z0-9_.]/gi, "");
}


/**
* Removes dangerous characters from a user-provided string that will be passed to ExternalInterface.call()
*
*/
public function cleanEIString(pString:String):String{
return pString.replace(/[^A-Za-z0-9_.]/gi, "");
}

/**
* Recursive function to sanitize an object (or array) before passing to ExternalInterface.call()
*/
private function cleanObject(obj:*):*{
if (obj is String) {
return obj.split("\\").join("\\\\");
} else if (obj is Array) {
var __sanitizedArray:Array = new Array();

for each (var __item in obj){
__sanitizedArray.push(cleanObject(__item));
}

return __sanitizedArray;
} else if (typeof(obj) == 'object') {
var __sanitizedObject:Object = new Object();

for (var __i in obj){
__sanitizedObject[__i] = cleanObject(obj[__i]);
}

return __sanitizedObject;
} else {
return obj;
}
}

private function initProvider():void{
if(_provider){
_provider.die();
Expand Down
30 changes: 16 additions & 14 deletions src/com/videojs/providers/HTTPVideoProvider.as
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ package com.videojs.providers{
private var _loadErrored:Boolean = false;
private var _pauseOnStart:Boolean = false;
private var _pausePending:Boolean = false;
private var _onmetadadataFired:Boolean = false;

/**
* The number of seconds between the logical start of the stream and the current zero
* playhead position of the NetStream. During normal, file-based playback this value should
Expand Down Expand Up @@ -246,12 +248,13 @@ package com.videojs.providers{
}

public function init(pSrc:Object, pAutoplay:Boolean):void{
_onmetadadataFired = false;
_src = pSrc;
_loadErrored = false;
_loadStarted = false;
_loadCompleted = false;
if(pAutoplay){
initNetConnection();
if (_model.preload) {
initNetConnection();
}
}

Expand Down Expand Up @@ -403,12 +406,7 @@ package com.videojs.providers{

if(_throughputTimer)
{
try {
_throughputTimer.stop();
_throughputTimer = null;
} catch( err: Error ) {

}
_throughputTimer.reset();
}
}

Expand Down Expand Up @@ -465,6 +463,7 @@ package com.videojs.providers{
_ns.client = this;
_ns.bufferTime = .5;
_ns.play(_src.path);
_ns.pause();
_videoReference.attachNetStream(_ns);

if (_src.path === null) {
Expand Down Expand Up @@ -524,11 +523,9 @@ package com.videojs.providers{
_loadStartTimestamp = getTimer();
_throughputTimer.reset();
_throughputTimer.start();
if(_pauseOnStart && _loadStarted == false){
_ns.pause();
_isPaused = true;
}
else{

if(!_pauseOnStart || _model.autoplay){
_ns.resume();
_model.broadcastEventExternally(ExternalEventName.ON_RESUME);
_model.broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent.ON_STREAM_START, {info:e.info}));
}
Expand All @@ -542,7 +539,6 @@ package com.videojs.providers{
break;

case "NetStream.Buffer.Full":
_model.broadcastEventExternally(ExternalEventName.ON_BUFFER_FULL);
_model.broadcastEventExternally(ExternalEventName.ON_CAN_PLAY);
_pausedSeekValue = -1;
_isPlaying = true;
Expand Down Expand Up @@ -631,6 +627,9 @@ package com.videojs.providers{
}

public function onMetaData(pMetaData:Object):void{
if (_onmetadadataFired) {
return;
}

_metadata = pMetaData;
if(pMetaData.duration != undefined){
Expand All @@ -644,6 +643,9 @@ package com.videojs.providers{
}
_model.broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent.ON_META_DATA, {metadata:_metadata}));
_model.broadcastEventExternally(ExternalEventName.ON_METADATA, _metadata);

_model.broadcastEventExternally(ExternalEventName.ON_BUFFER_FULL);
_onmetadadataFired = true;
}

public function onCuePoint(pInfo:Object):void{
Expand Down

0 comments on commit e8b78be

Please sign in to comment.