Created
December 19, 2014 21:25
-
-
Save dmlap/b87f732d3add5199719f to your computer and use it in GitHub Desktop.
Modifying a video's sources before loading it into a Brightcove Player.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<video | |
data-account="1234" | |
data-player="abc-123" | |
data-embed="default" | |
class="video-js" controls></video> | |
<script src="//players.brightcove.net/1234/abc-123_default/index.min.js"></script> | |
<script> | |
var player = videojs(document.querySelector('video')); | |
player.catalog.getVideo('17', function(error, video) { | |
if (error) { | |
return alert('uh-oh! ' + error); | |
} | |
// Favor the highest quality sources by sorting based on their | |
// total size. Larger sizes correspond to higher quality. | |
video.sources.sort(function(left, right) { | |
var rightSize = right.size || 0, leftSize = left.size || 0; | |
return rightSize - leftSize; | |
}); | |
// load the updated video into the player | |
player.catalog.load(video); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment