From 26dd7debe31bfb28cac6dbb44de5e45503ba1c55 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 17 May 2011 18:02:25 +0200 Subject: [PATCH] support multiple resolutions per video player --- demos/video/js/video.js | 10 +- source/Ox.UI/js/Video/Ox.VideoPlayer.js | 160 +++++++++++++++++++++--- 2 files changed, 153 insertions(+), 17 deletions(-) diff --git a/demos/video/js/video.js b/demos/video/js/video.js index 25ff9b12..7065a38c 100644 --- a/demos/video/js/video.js +++ b/demos/video/js/video.js @@ -32,7 +32,7 @@ Ox.load('UI', { videoSize = getVideoSize(), $videos = [ Ox.VideoPlayer({ - controlsBottom: ['play', 'volume', 'scale', 'timeline', 'position'], + controlsBottom: ['play', 'volume', 'scale', 'timeline', 'position', 'resolution'], controlsTop: ['fullscreen', 'title', 'find'], enableFind: true, enableFullscreen: true, @@ -45,12 +45,16 @@ Ox.load('UI', { logo: 'png/logo.png', paused: true, poster: poster, - showIconOnLoad: true, + //showIconOnLoad: true, showProgress: false, subtitles: 'srt/' + id + '.srt', timeline: 'png/timeline.16.png', title: 'Brick - Rian Johnson - 2005', - video: url + '?' + + Ox.random(1000000), + video: { + 96: url + '?' + + Ox.random(1000000), + 360: url + '?' + + Ox.random(1000000), + 1080: url + '?' + + Ox.random(1000000) + }, width: 360 }) .css({ diff --git a/source/Ox.UI/js/Video/Ox.VideoPlayer.js b/source/Ox.UI/js/Video/Ox.VideoPlayer.js index b4a60bc8..e237c4fb 100644 --- a/source/Ox.UI/js/Video/Ox.VideoPlayer.js +++ b/source/Ox.UI/js/Video/Ox.VideoPlayer.js @@ -13,8 +13,8 @@ Ox.VideoPlayer Generic Video Player controls <[[s]]|[[][]]> Controls, first top, then bottom, from left to right Can be 'fullscreen', 'scale', 'title', 'find', 'menu', 'play', 'playInToOut', 'mute', 'volume', 'size', 'timeline', 'space', - 'position', 'settings'. The 'space' control is just empty space - that separates left-aligned from right-aligned controls. + 'position', 'resolution', 'settings'. The 'space' control is just + empty space that separates left-aligned from right-aligned controls. duration Duration (sec) enableFind If true, enable find enableFullscreen If true, enable fullscreen @@ -40,6 +40,7 @@ Ox.VideoPlayer Generic Video Player posterFrame Position of poster frame (sec) preload 'auto', 'metadata' or 'none' out Out point (sec) + resolution resolution scaleToFill If true, scale to fill (otherwise, scale to fit) showFind If true, show find input showHours If true, don't show hours for videos shorter than one hour @@ -58,7 +59,8 @@ Ox.VideoPlayer Generic Video Player timeline Timeline image URL title Video title type 'play', 'in' or 'out' - video Video URL + video Video URL + String or object ({resolution: url, resolution: url, ...}) volume Volume (0-1) width Width in px @*/ @@ -96,6 +98,7 @@ Ox.VideoPlayer = function(options, self) { poster: '', preload: 'auto', out: 0, + resolution: 0, scaleToFill: false, showFind: false, showHours: false, @@ -126,6 +129,17 @@ Ox.VideoPlayer = function(options, self) { } }); + if (Ox.isString(self.options.video)) { + self.video = self.options.video; + } else { + self.resolutions = Ox.sort(Object.keys(self.options.video)); + if (!(self.options.resolution in self.options.video)) { + self.options.resolution = self.resolutions[0]; + } + Ox.print('resolutions', self.resolutions) + self.video = self.options.video[self.options.resolution]; + } + self['in'] = self.options.playInToOut ? self.options['in'] : 0, self.out = self.options.playInToOut ? self.options.out : self.options.duration; self.options.duration = self.out - self['in']; @@ -268,7 +282,7 @@ Ox.VideoPlayer = function(options, self) { self.$video = $('