Commit 0216a0fd by Valera Rozuvan

Fixed bugs. Removed unnecessary things from HTML5. Minor improvements. Subtitles…

Fixed bugs. Removed unnecessary things from HTML5. Minor improvements. Subtitles now work in HTML5 if specified.
parent 83f18fed
...@@ -6,8 +6,7 @@ class @VideoAlpha ...@@ -6,8 +6,7 @@ class @VideoAlpha
@end = @el.data('end') @end = @el.data('end')
@caption_data_dir = @el.data('caption-data-dir') @caption_data_dir = @el.data('caption-data-dir')
@caption_asset_path = @el.data('caption-asset-path') @caption_asset_path = @el.data('caption-asset-path')
@show_captions = @el.data('show-captions') == "true" @show_captions = @el.data('show-captions').toString() == "true"
window.player = null
@el = $("#video_#{@id}") @el = $("#video_#{@id}")
if @parseVideos(@el.data("streams")) is true if @parseVideos(@el.data("streams")) is true
@videoType = "youtube" @videoType = "youtube"
......
...@@ -15,9 +15,6 @@ this.HTML5Video = (function () { ...@@ -15,9 +15,6 @@ this.HTML5Video = (function () {
* follows: * follows:
* *
* config = { * config = {
* 'width': 640,
*
* 'height': 390,
* *
* 'videoSources': {}, // An object of with properties being video sources. The property name is the * 'videoSources': {}, // An object of with properties being video sources. The property name is the
* // video format of the source. Supported video formats are: 'mp4', 'webm', and * // video format of the source. Supported video formats are: 'mp4', 'webm', and
...@@ -26,11 +23,7 @@ this.HTML5Video = (function () { ...@@ -26,11 +23,7 @@ this.HTML5Video = (function () {
* // 'videoSource' option, you can later call loadVideoBySource() method to load * // 'videoSource' option, you can later call loadVideoBySource() method to load
* // a video and start playing it. * // a video and start playing it.
* *
* 'playerVars': { // Object's properties identify player parameters. * 'playerVars': { // Object's properties identify player parameters. *
*
* 'controls': 1, // Possible values: 0, or 1. Value of 1 will enable the default browser video
* // controls.
*
* 'start': null, // Possible values: positive integer. Position from which to start playing the * 'start': null, // Possible values: positive integer. Position from which to start playing the
* // video. Measured in seconds. If value is null, or 'start' property is not * // video. Measured in seconds. If value is null, or 'start' property is not
* // specified, the video will start playing from the beginning. * // specified, the video will start playing from the beginning.
...@@ -47,8 +40,7 @@ this.HTML5Video = (function () { ...@@ -47,8 +40,7 @@ this.HTML5Video = (function () {
* // called for that event. * // called for that event.
* *
* 'onReady': null, * 'onReady': null,
* 'onStateChange': null, * 'onStateChange': null
* 'onPlaybackQualityChange': null
* } * }
* } * }
*/ */
...@@ -172,40 +164,6 @@ this.HTML5Video = (function () { ...@@ -172,40 +164,6 @@ this.HTML5Video = (function () {
this.videoEl.appendTo(this.el.find('.video-player div')); this.videoEl.appendTo(this.el.find('.video-player div'));
} }
/*
* This function returns the quality of the video. Possible return values are (type String)
*
* highres
* hd1080
* hd720
* large
* medium
* small
*
* It returns undefined if there is no current video.
*
* If there is a current video, but it is impossible to determine it's quality, the function will return
* 'medium'.
*/
Player.prototype.getPlayBackQuality = function () {
if (this.config.videoSource === '') {
return undefined;
}
// TODO: Figure out if we can get the quality of a video from a source (when it is loaded by the browser).
return 'medium';
};
/*
* The original YouTube API function player.setPlaybackQuality changed (if it was possible) the quality of the
* played video. In our case, this function will not do anything because we can't change the quality of HTML5
* video since we only get one source of video with one quality.
*/
Player.prototype.setPlaybackQuality = function (value) {
};
Player.prototype.pauseVideo = function () { Player.prototype.pauseVideo = function () {
this.video.pause(); this.video.pause();
}; };
...@@ -216,28 +174,6 @@ this.HTML5Video = (function () { ...@@ -216,28 +174,6 @@ this.HTML5Video = (function () {
} }
}; };
// YouTube API has player.loadVideoById, but since we are working with a video source, we will rename this
// function accordingly. However, not to cause conflicts, there will also be a loadVideoById function which
// will call this function.
Player.prototype.loadVideoBySource = function (source) {
};
Player.prototype.loadVideoById = function (id) {
this.loadVideoBySource(id);
}
// YouTube API has player.cueVideoById, but since we are working with a video source, we will rename this
// function accordingly. However, not to cause conflicts, there will also be a cueVideoById function which
// will call this function.
Player.prototype.cueVideoBySource = function (source) {
};
Player.prototype.cueVideoById = function (id) {
this.cueVideoBySource(id);
};
Player.prototype.setVolume = function (value) { Player.prototype.setVolume = function (value) {
if ((typeof value === 'number') && (value <= 100) && (value >= 0)) { if ((typeof value === 'number') && (value <= 100) && (value >= 0)) {
this.video.volume = value * 0.01; this.video.volume = value * 0.01;
...@@ -253,7 +189,7 @@ this.HTML5Video = (function () { ...@@ -253,7 +189,7 @@ this.HTML5Video = (function () {
}; };
Player.prototype.getPlayerState = function () { Player.prototype.getPlayerState = function () {
return this.playerState;
}; };
Player.prototype.getVolume = function () { Player.prototype.getVolume = function () {
...@@ -272,7 +208,11 @@ this.HTML5Video = (function () { ...@@ -272,7 +208,11 @@ this.HTML5Video = (function () {
if (isFinite(newSpeed) === true) { if (isFinite(newSpeed) === true) {
this.video.playbackRate = value; this.video.playbackRate = value;
} }
} };
Player.prototype.getAvailablePlaybackRates = function () {
return [0.75, 1.0, 1.25, 1.5];
};
return Player; return Player;
}()); }());
......
class @VideoPlayerAlpha extends SubviewAlpha class @VideoPlayerAlpha extends SubviewAlpha
initialize: -> initialize: ->
if (window.OldVideoPlayerAlpha) and (window.OldVideoPlayerAlpha.onPause)
window.OldVideoPlayerAlpha.onPause()
window.OldVideoPlayerAlpha = this
if @video.videoType is 'youtube' if @video.videoType is 'youtube'
@PlayerState = YT.PlayerState @PlayerState = YT.PlayerState
# Define a missing constant of Youtube API # Define a missing constant of Youtube API
...@@ -11,10 +14,10 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -11,10 +14,10 @@ class @VideoPlayerAlpha extends SubviewAlpha
@el = $("#video_#{@video.id}") @el = $("#video_#{@video.id}")
bind: -> bind: ->
console.log "show_captions = #{@video.show_captions}"
$(@control).bind('play', @play) $(@control).bind('play', @play)
.bind('pause', @pause) .bind('pause', @pause)
$(@qualityControl).bind('changeQuality', @handlePlaybackQualityChange) if @video.videoType is 'youtube'
$(@qualityControl).bind('changeQuality', @handlePlaybackQualityChange)
if @video.show_captions is true if @video.show_captions is true
$(@caption).bind('seek', @onSeek) $(@caption).bind('seek', @onSeek)
$(@speedControl).bind('speedChange', @onSpeedChange) $(@speedControl).bind('speedChange', @onSpeedChange)
...@@ -32,7 +35,8 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -32,7 +35,8 @@ class @VideoPlayerAlpha extends SubviewAlpha
render: -> render: ->
@control = new VideoControlAlpha el: @$('.video-controls') @control = new VideoControlAlpha el: @$('.video-controls')
@qualityControl = new VideoQualityControlAlpha el: @$('.secondary-controls') if @video.videoType is 'youtube'
@qualityControl = new VideoQualityControlAlpha el: @$('.secondary-controls')
if @video.show_captions is true if @video.show_captions is true
@caption = new VideoCaptionAlpha @caption = new VideoCaptionAlpha
el: @el el: @el
...@@ -63,7 +67,6 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -63,7 +67,6 @@ class @VideoPlayerAlpha extends SubviewAlpha
events: events:
onReady: @onReady onReady: @onReady
onStateChange: @onStateChange onStateChange: @onStateChange
onPlaybackQualityChange: @onPlaybackQualityChange
else if @video.videoType is 'youtube' else if @video.videoType is 'youtube'
@player = new YT.Player @video.id, @player = new YT.Player @video.id,
playerVars: @playerVars playerVars: @playerVars
...@@ -110,8 +113,6 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -110,8 +113,6 @@ class @VideoPlayerAlpha extends SubviewAlpha
onPlay: => onPlay: =>
@video.log 'play_video' @video.log 'play_video'
window.player.pauseVideo() if window.player && window.player != @player
window.player = @player
unless @player.interval unless @player.interval
@player.interval = setInterval(@update, 200) @player.interval = setInterval(@update, 200)
if @video.show_captions is true if @video.show_captions is true
...@@ -121,7 +122,6 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -121,7 +122,6 @@ class @VideoPlayerAlpha extends SubviewAlpha
onPause: => onPause: =>
@video.log 'pause_video' @video.log 'pause_video'
window.player = null if window.player == @player
clearInterval(@player.interval) clearInterval(@player.interval)
@player.interval = null @player.interval = null
if @video.show_captions is true if @video.show_captions is true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment