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

Bugfix for dispose when changing techs. #2125

Closed
wants to merge 2 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
11 changes: 3 additions & 8 deletions src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ vjs.Flash = vjs.MediaTechController.extend({

var source = options['source'],

// Which element to embed in
parentEl = options['parentEl'],

// Create a temporary element to be replaced by swf object
placeHolder = this.el_ = vjs.createEl('div', { id: player.id() + '_temp_flash' }),

// Generate ID for swf object
objId = player.id()+'_flash_api',

Expand Down Expand Up @@ -71,7 +65,7 @@ vjs.Flash = vjs.MediaTechController.extend({
}

// Add placeholder to player div
vjs.insertFirst(placeHolder, parentEl);
vjs.insertFirst(this.el_, options['parentEl']);

// Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
Expand All @@ -98,7 +92,7 @@ vjs.Flash = vjs.MediaTechController.extend({
// use stageclick events triggered from inside the SWF instead
player.on('stageclick', player.reportUserActivity);

this.el_ = vjs.Flash.embed(options['swf'], placeHolder, flashVars, params, attributes);
this.el_ = vjs.Flash.embed(options['swf'], this.el_, flashVars, params, attributes);
}
});

Expand Down Expand Up @@ -365,6 +359,7 @@ vjs.Flash.embed = function(swf, placeHolder, flashVars, params, attributes){
;

placeHolder.parentNode.replaceChild(obj, placeHolder);
obj[vjs.expando] = placeHolder[vjs.expando];

// IE6 seems to have an issue where it won't initialize the swf object after injecting it.
// This is a dumb fix
Expand Down
31 changes: 31 additions & 0 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,34 @@ test('should add an audio class if an audio el is used', function() {

ok(player.el().className.indexOf(audioClass) !== -1, 'added '+ audioClass +' css class');
});

test('dispose should not throw exceptions when changing the tech', function() {
var fixture, video, player, id;
fixture = document.getElementById('qunit-fixture');

video = document.createElement('video');
video.className = 'vjs-default-skin video-js';
fixture.appendChild(video);

player = videojs(video);

player.loadTech('Flash');
player.controls(true);

player.loadTech('Html5');
player.src({
src: 'http://media.sundaysky.com/oat/videos/SGE2015_mp4/clip.mp4',
type: 'video/mp4'
});

player.trigger('loadstart');
player.trigger('loadedmetadata');
player.trigger('timeupdate');

try {
player.dispose();
} catch (e) {
return equal(e, undefined, 'threw an exception');
}
ok(true, 'no exception was thrown');
});