Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle error getter on flash tech better #2515

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,8 @@ class Player extends Component {
* @event error
*/
handleTechError() {
this.error(this.tech.error().code);
let error = this.tech.error();
this.error(error && error.code);
}

/**
Expand Down
27 changes: 21 additions & 6 deletions src/js/tech/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ class Flash extends Tech {
return createTimeRange(0, this.el_.vjs_getProperty('buffered'));
}

/**
* Get the last error object
*
* @return {Object}
* @method error
*/
error() {
let error = this.error_;
this.error_ = null;
return error || null;
}

/**
* Get fullscreen support -
* Flash does not allow fullscreen through javascript
Expand Down Expand Up @@ -297,7 +309,7 @@ class Flash extends Tech {
// Create setters and getters for attributes
const _api = Flash.prototype;
const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
const _readOnly = 'error,networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
const _readOnly = 'networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove error.


function _createSetter(attr){
var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
Expand Down Expand Up @@ -438,14 +450,17 @@ Flash.onEvent = function(swfID, eventName){
Flash.onError = function(swfID, err){
const tech = Dom.getEl(swfID).tech;
const msg = 'FLASH: '+err;
const errorObj = {
message: msg
};

if (err === 'srcnotfound') {
tech.trigger('error', { code: 4, message: msg });
tech.error_ = errorObj;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store the error object for usage above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also make tech.error a setter that handles this part, but either way is fine.


// errors we haven't categorized into the media errors
} else {
tech.trigger('error', msg);
if (err === 'srcnotfound') {
errorObj.code = 4;
}

tech.trigger('error', errorObj);
};

// Flash Version Check
Expand Down