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
.bootstrap .multiselect-container { | |
position: absolute; | |
list-style-type: none; | |
margin: 0; | |
padding: 0; | |
} | |
.bootstrap .multiselect-container .input-group { | |
margin: 5px; | |
} | |
.bootstrap .multiselect-container > li { |
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
define(function(require) { | |
'use strict'; | |
require('backbone.marionette'); | |
Marionette.Region.buildRegion = function(regionConfig, DefaultRegionClass) { | |
if (_.isString(regionConfig)) { | |
regionConfig = '[data-region=' + regionConfig + ']'; | |
return this._buildRegionFromSelector(regionConfig, DefaultRegionClass); | |
} |
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
_setCurrentTime: function(playerState, currentTimeHighPrecision, timestamp) { | |
// If the player is playing then currentTimeHighPrecision will be slightly out-of-sync due to the time it takes to request | |
// the information. So, subtract an offset of the time it took to receive the message. | |
if (playerState === PlayerState.Playing) { | |
var offset = performance.now() - timestamp; | |
currentTimeHighPrecision -= offset * .001; | |
} | |
this.el.currentTime = currentTimeHighPrecision; | |
} |
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
// Send a message to YouTube's iframe to figure out what the current time is of the video element inside of the iframe. | |
requestCurrentTimeHighPrecision: function() { | |
var iframePort = this.get('iframePort'); | |
iframePort.postMessage('getCurrentTimeHighPrecision'); | |
} | |
_onYouTubeIFrameMessage: function(message) { | |
if (!_.isUndefined(message.currentTimeHighPrecision)) { | |
this.trigger('receive:currentTimeHighPrecision', this, message); | |
} |
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
// Create the port needed to communicate with the parent extension. | |
this.initializePort = function() { | |
this.port = chrome.runtime.connect({ | |
name: 'youTubeIFrameConnectRequest' | |
}); | |
// The extension can request the *exact* time of YouTube's video player. | |
// Respond with that value, but also include a timestamp to account for the time it takes to send the postMessage. | |
this.port.onMessage.addListener(function(message) { | |
if (message === 'getCurrentTimeHighPrecision') { |
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
var SourceBufferWrapper = Backbone.Model.extend({ | |
defaults: function() { | |
return { | |
sourceBuffer: null, | |
appendedBufferCount: 0, | |
// Buffered data which has already been leveraged by YouTube is cached on the background page and re-used as needed. | |
bufferCache: [] | |
}; | |
}, |
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
var SourceBufferWrapper = require('foreground/model/sourceBufferWrapper'); | |
var MediaSourceWrapper = Backbone.Model.extend({ | |
defaults: function() { | |
return { | |
mediaSource: new window.MediaSource(), | |
sourceBufferWrapper: null, | |
// The video encoding format and codec used to render mediaSource; i.e. video/webm codecs="vp9" | |
bufferType: '', | |
// The URL which points to mediaSource's data |
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
var MediaSourceWrapper = require('foreground/model/mediaSourceWrapper'); | |
var VideoView = Marionette.ItemView.extend({ | |
el: '#video', | |
mediaSourceWrapper: null, | |
mediaSourceWrapperEvents: { | |
'change:objectURL': '_onMediaSourceWrapperChangeObjectURL' | |
}, |
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
<html> | |
<head> | |
<title>Foreground</title> | |
<link rel="stylesheet" href="foreground.css"> | |
</head> | |
<body> | |
<div class="video-container"> | |
<video id='video'></video> | |
</div> | |
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
_onWindowMessage: function(message) { | |
// When receiving a message of buffer data from YouTube's API, store it. | |
if (message.data && message.data.buffer) { | |
this.get('buffers').push(message.data.buffer); | |
this.set('bufferType', message.data.bufferType); | |
} | |
}, |