2011-05-16 10:49:48 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
|
|
|
|
2011-05-12 22:12:41 +00:00
|
|
|
/*@
|
2011-05-13 15:44:50 +00:00
|
|
|
Ox.VideoPlayer <f> Generic Video Player
|
2011-05-12 22:12:41 +00:00
|
|
|
(options, self) -> <o> Video Player
|
|
|
|
options <o> Options
|
2011-05-13 15:44:50 +00:00
|
|
|
annotation <[o]> Array of annotation tracks
|
|
|
|
name <s> Name of the annotation track
|
|
|
|
data <[o]> Annotation data
|
|
|
|
in <n> In point (sec)
|
|
|
|
out <n> Out point (sec)
|
|
|
|
text <s> Text
|
2011-05-16 18:05:29 +00:00
|
|
|
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',
|
2011-05-17 16:02:25 +00:00
|
|
|
'position', 'resolution', 'settings'. The 'space' control is just
|
|
|
|
empty space that separates left-aligned from right-aligned controls.
|
2011-05-13 15:44:50 +00:00
|
|
|
duration <n|-1> Duration (sec)
|
2011-05-16 11:29:26 +00:00
|
|
|
enableFind <b|false> If true, enable find
|
|
|
|
enableFullscreen <b|false> If true, enable fullscreen
|
2011-05-13 15:44:50 +00:00
|
|
|
enableKeyboard <b|false> If true, enable keyboard controls
|
|
|
|
externalControls <b|false> If true, controls are outside the video
|
2011-05-15 16:18:58 +00:00
|
|
|
find <s|''> Query string
|
2011-05-13 15:44:50 +00:00
|
|
|
focus <s|'click'> focus on 'click', 'load' or 'mouseover'
|
|
|
|
fps <n|25> Frames per second
|
2011-05-15 07:26:00 +00:00
|
|
|
fullscreen <b|false> If true, video is in fullscreen
|
2011-05-13 15:44:50 +00:00
|
|
|
height <n|144> Height in px (excluding external controls)
|
|
|
|
in <n> In point (sec)
|
|
|
|
keepIconVisible <b|false> If true, play icon stays visible after mouseleave
|
|
|
|
keepLargeTimelineVisible <b|false> If true, large timeline stays visible after mouseleave
|
|
|
|
keepLogoVisible <b|false> If true, logo stays visible after mouseleave
|
|
|
|
logo <s|''> Logo image URL
|
|
|
|
logoLink <s|''> Logo link URL
|
|
|
|
logoTitle <s|''> Text for tooltip
|
|
|
|
muted <b|false> If true, video is muted
|
|
|
|
paused <b|false> If true, video is paused
|
|
|
|
playInToOut <b|false> If true, video plays only from in to out
|
|
|
|
position <n|0> Initial position (sec)
|
|
|
|
poster <s|''> Poster URL
|
|
|
|
posterFrame <n|-1> Position of poster frame (sec)
|
|
|
|
preload <s|'auto'> 'auto', 'metadata' or 'none'
|
|
|
|
out <n|-1> Out point (sec)
|
2011-05-17 16:02:25 +00:00
|
|
|
resolution <n|0> resolution
|
2011-05-13 15:44:50 +00:00
|
|
|
scaleToFill <b|false> If true, scale to fill (otherwise, scale to fit)
|
|
|
|
showFind <b|false> If true, show find input
|
|
|
|
showHours <b|false> If true, don't show hours for videos shorter than one hour
|
|
|
|
showIcon <b|false> If true, show play icon
|
|
|
|
showIconOnLoad <b|false> If true, show icon on load
|
2011-05-14 19:32:49 +00:00
|
|
|
showInterfaceOnLoad <b|false> If true, show controls and title on load
|
2011-05-13 15:44:50 +00:00
|
|
|
showLargeTimeline <b|false> If true, show large timeline
|
2011-05-14 19:32:49 +00:00
|
|
|
showMilliseconds <n|0> Number of decimals to show
|
2011-05-13 15:44:50 +00:00
|
|
|
showPointMarkers <b|false> If true, show in/out markers
|
2011-05-14 19:32:49 +00:00
|
|
|
showProgress <|false> If true, show buffering progress
|
2011-05-13 15:44:50 +00:00
|
|
|
sizeIsLarge <b|false> If true, initial state of the size control is large
|
|
|
|
subtitles <s|[o]|[]> URL or SRT or array of subtitles
|
|
|
|
in <n> In point (sec)
|
|
|
|
out <n> Out point (sec)
|
2011-05-12 22:12:41 +00:00
|
|
|
text <s> Text
|
2011-05-13 15:44:50 +00:00
|
|
|
timeline <s> Timeline image URL
|
|
|
|
title <s|''> Video title
|
|
|
|
type <s|'play'> 'play', 'in' or 'out'
|
2011-05-17 16:02:25 +00:00
|
|
|
video <s|o|''> Video URL
|
|
|
|
String or object ({resolution: url, resolution: url, ...})
|
2011-05-13 15:44:50 +00:00
|
|
|
volume <n|1> Volume (0-1)
|
|
|
|
width <n|256> Width in px
|
2011-05-12 22:12:41 +00:00
|
|
|
@*/
|
|
|
|
|
2011-05-12 10:39:48 +00:00
|
|
|
Ox.VideoPlayer = function(options, self) {
|
|
|
|
|
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
|
|
|
.defaults({
|
2011-05-13 15:44:50 +00:00
|
|
|
annotations: [],
|
2011-05-16 18:05:29 +00:00
|
|
|
controlsBottom: [],
|
|
|
|
controlsTop: [],
|
2011-05-16 11:29:26 +00:00
|
|
|
duration: 0,
|
|
|
|
enableFind: false,
|
|
|
|
enableFullscreen: false,
|
2011-05-13 15:44:50 +00:00
|
|
|
enableKeyboard: false,
|
|
|
|
externalControls: false,
|
2011-05-15 16:18:58 +00:00
|
|
|
find: '',
|
2011-05-13 15:44:50 +00:00
|
|
|
focus: 'click',
|
|
|
|
fps: 25,
|
2011-05-15 07:26:00 +00:00
|
|
|
fullscreen: false,
|
2011-05-13 15:44:50 +00:00
|
|
|
height: 144,
|
2011-05-14 19:32:49 +00:00
|
|
|
'in': 0,
|
2011-05-13 15:44:50 +00:00
|
|
|
keepIconVisible: false,
|
|
|
|
keepLargeTimelineVisible: false,
|
|
|
|
keepLogoVisible: false,
|
2011-05-17 08:58:03 +00:00
|
|
|
largeTimeline: false,
|
2011-05-13 15:44:50 +00:00
|
|
|
logo: '',
|
2011-05-12 22:12:41 +00:00
|
|
|
logoLink: '',
|
|
|
|
logoTitle: '',
|
2011-05-13 15:44:50 +00:00
|
|
|
muted: false,
|
|
|
|
paused: false,
|
|
|
|
playInToOut: false,
|
2011-05-12 10:39:48 +00:00
|
|
|
position: 0,
|
2011-05-13 15:44:50 +00:00
|
|
|
poster: '',
|
|
|
|
preload: 'auto',
|
2011-05-14 19:32:49 +00:00
|
|
|
out: 0,
|
2011-05-17 16:02:25 +00:00
|
|
|
resolution: 0,
|
2011-05-13 15:44:50 +00:00
|
|
|
scaleToFill: false,
|
|
|
|
showFind: false,
|
|
|
|
showHours: false,
|
|
|
|
showIcon: false,
|
|
|
|
showIconOnLoad: false,
|
2011-05-14 19:32:49 +00:00
|
|
|
showInterfaceOnLoad: false,
|
2011-05-13 15:44:50 +00:00
|
|
|
showLargeTimeline: false,
|
2011-05-14 19:32:49 +00:00
|
|
|
showMilliseconds: 0,
|
2011-05-13 15:44:50 +00:00
|
|
|
showPointMarkers: false,
|
2011-05-14 19:32:49 +00:00
|
|
|
showProgress: false,
|
2011-05-12 22:12:41 +00:00
|
|
|
subtitles: [],
|
2011-05-13 15:44:50 +00:00
|
|
|
timeline: '',
|
2011-05-12 22:12:41 +00:00
|
|
|
title: '',
|
2011-05-13 15:44:50 +00:00
|
|
|
type: 'play',
|
|
|
|
video: '',
|
|
|
|
volume: 1,
|
2011-05-12 10:39:48 +00:00
|
|
|
width: 256
|
|
|
|
})
|
|
|
|
.options(options || {})
|
2011-05-14 19:32:49 +00:00
|
|
|
.addClass('OxVideo')
|
2011-05-12 10:39:48 +00:00
|
|
|
.css({
|
2011-05-13 15:44:50 +00:00
|
|
|
position: 'absolute'
|
2011-05-12 10:39:48 +00:00
|
|
|
});
|
|
|
|
|
2011-05-15 07:26:00 +00:00
|
|
|
Ox.UI.$window.bind({
|
|
|
|
resize: function() {
|
|
|
|
self.options.fullscreen && setSizes();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-05-17 16:02:25 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
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'];
|
|
|
|
self.options.position = Ox.limit(self.options.position, self['in'], self.out);
|
2011-05-17 18:44:53 +00:00
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
self.millisecondsPerFrame = 1000 / self.options.fps;
|
|
|
|
self.secondsPerFrame = 1 / self.options.fps;
|
|
|
|
self.barHeight = 16;
|
2011-05-15 07:26:00 +00:00
|
|
|
self.width = self.options.fullscreen ? window.innerWidth : self.options.width;
|
|
|
|
self.height = self.options.fullscreen ? window.innerHeight : self.options.height;
|
2011-05-14 19:32:49 +00:00
|
|
|
|
|
|
|
if (self.options.enableKeyboard) {
|
|
|
|
that.bindEvent({
|
2011-05-17 18:01:40 +00:00
|
|
|
key_0: toggleMuted,
|
|
|
|
key_1: toggleScale,
|
2011-05-17 10:34:55 +00:00
|
|
|
key_equal: function() {
|
|
|
|
changeVolumeBy(0.1);
|
|
|
|
},
|
2011-05-16 11:29:26 +00:00
|
|
|
key_f: function() {
|
|
|
|
// need timeout so the "f" doesn't appear in the input field
|
2011-05-17 09:05:59 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
if (self.$find.is(':hidden')) {
|
|
|
|
toggleFind();
|
|
|
|
} else {
|
|
|
|
self.$findInput.focusInput();
|
|
|
|
}
|
|
|
|
}, 0);
|
2011-05-16 11:29:26 +00:00
|
|
|
},
|
|
|
|
key_g: function() {
|
|
|
|
goToNextResult(1);
|
|
|
|
},
|
2011-05-14 19:32:49 +00:00
|
|
|
key_left: function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(self.options.position - self.secondsPerFrame);
|
2011-05-15 08:35:00 +00:00
|
|
|
},
|
2011-05-17 10:34:55 +00:00
|
|
|
key_minus: function() {
|
|
|
|
changeVolumeBy(-0.1);
|
2011-05-16 18:05:29 +00:00
|
|
|
},
|
2011-05-15 08:35:00 +00:00
|
|
|
key_p: function() {
|
|
|
|
playInToOut();
|
2011-05-14 19:32:49 +00:00
|
|
|
},
|
|
|
|
key_right: function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(self.options.position + self.secondsPerFrame);
|
2011-05-14 19:32:49 +00:00
|
|
|
},
|
2011-05-15 07:52:37 +00:00
|
|
|
key_shift_f: function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
self.options.enableFullscreen && toggleFullscreen();
|
2011-05-16 11:29:26 +00:00
|
|
|
},
|
|
|
|
key_shift_g: function() {
|
|
|
|
goToNextResult(-1);
|
2011-05-15 07:52:37 +00:00
|
|
|
},
|
2011-05-17 20:20:43 +00:00
|
|
|
key_shift_left: function() {
|
|
|
|
setPosition(self.options.position - 1);
|
|
|
|
},
|
|
|
|
key_shift_right: function() {
|
|
|
|
setPosition(self.options.position + 1);
|
|
|
|
},
|
2011-05-17 18:01:40 +00:00
|
|
|
key_space: togglePaused
|
2011-05-14 19:32:49 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self.options.enableKeyboard) {
|
|
|
|
if (self.options.focus == 'mouseenter') {
|
|
|
|
that.bind({
|
2011-05-15 16:18:58 +00:00
|
|
|
mouseenter: function() {
|
|
|
|
if (!self.inputHasFocus) {
|
|
|
|
that.gainFocus();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
that.loseFocus();
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
that.bind({
|
|
|
|
click: that.gainFocus
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-15 16:18:58 +00:00
|
|
|
if (
|
2011-05-16 18:05:29 +00:00
|
|
|
(!self.options.externalControls &&
|
|
|
|
(self.options.controlsTop.length || self.options.controlsBottom.length)) ||
|
|
|
|
self.options.showIcon
|
2011-05-15 16:18:58 +00:00
|
|
|
) {
|
2011-05-13 15:44:50 +00:00
|
|
|
that.bind({
|
2011-05-15 16:18:58 +00:00
|
|
|
mouseenter: function() {
|
|
|
|
showInterface();
|
|
|
|
self.mouseHasLeft = false;
|
|
|
|
Ox.print('MOUSE HAS ENTERED')
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
hideInterface();
|
|
|
|
self.mouseHasLeft = true;
|
|
|
|
Ox.print('MOUSE HAS LEFT')
|
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-05-12 22:12:41 +00:00
|
|
|
if (Ox.isString(self.options.subtitles)) {
|
|
|
|
if (self.options.subtitles.indexOf('\n') > -1) {
|
|
|
|
self.options.subtitles = Ox.parseSRT(self.options.subtitles);
|
|
|
|
} else {
|
|
|
|
Ox.get(self.options.subtitles, function(data) {
|
|
|
|
self.options.subtitles = Ox.parseSRT(data);
|
2011-05-16 11:29:26 +00:00
|
|
|
self.results = find(self.options.find);
|
|
|
|
Ox.print('--setting results--', self.$timeline)
|
|
|
|
if (self.options.duration) {
|
2011-05-17 08:58:03 +00:00
|
|
|
// video has loaded
|
2011-05-16 11:29:26 +00:00
|
|
|
self.$timeline && self.$timeline.options({
|
|
|
|
results: self.results,
|
|
|
|
subtitles: self.options.subtitles
|
|
|
|
});
|
2011-05-17 08:58:03 +00:00
|
|
|
self.$largeTimeline && self.$largeTimeline.options({
|
|
|
|
subtitles: self.options.subtitles
|
|
|
|
});
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
2011-05-12 22:12:41 +00:00
|
|
|
});
|
2011-05-16 11:29:26 +00:00
|
|
|
self.options.subtitles = [];
|
2011-05-12 22:12:41 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-16 11:29:26 +00:00
|
|
|
self.results = find(self.options.find);
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-12 10:39:48 +00:00
|
|
|
self.buffered = [];
|
|
|
|
self.controlsTimeout;
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
self.$videoContainer = $('<div>')
|
2011-05-12 10:39:48 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
2011-05-17 07:05:21 +00:00
|
|
|
top: self.options.externalControls && self.options.controlsTop ? '16px' : 0,
|
2011-05-14 19:32:49 +00:00
|
|
|
background: 'rgb(0, 0, 0)',
|
2011-05-13 15:44:50 +00:00
|
|
|
overflow: 'hidden'
|
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.bind({
|
|
|
|
click: function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
|
|
|
})
|
2011-05-13 15:44:50 +00:00
|
|
|
.appendTo(that.$element)
|
|
|
|
|
|
|
|
self.$video = $('<video>')
|
|
|
|
.attr(Ox.extend({
|
|
|
|
preload: self.options.preload,
|
2011-05-17 16:02:25 +00:00
|
|
|
src: self.video
|
2011-05-13 15:44:50 +00:00
|
|
|
}, !self.options.paused ? {
|
|
|
|
autoplay: 'autoplay'
|
2011-05-14 19:32:49 +00:00
|
|
|
} : {}/*, self.options.poster ? {
|
2011-05-13 15:44:50 +00:00
|
|
|
poster: self.options.poster
|
2011-05-14 19:32:49 +00:00
|
|
|
} : {}*/))
|
2011-05-13 15:44:50 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute'
|
2011-05-12 10:39:48 +00:00
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.bind(Ox.extend({
|
2011-05-13 15:44:50 +00:00
|
|
|
ended: ended,
|
2011-05-12 10:39:48 +00:00
|
|
|
loadedmetadata: loadedmetadata,
|
2011-05-13 15:44:50 +00:00
|
|
|
seeked: seeked,
|
|
|
|
seeking: seeking
|
2011-05-14 19:32:49 +00:00
|
|
|
}, self.options.progress ? {
|
|
|
|
progress: progress
|
|
|
|
} : {}))
|
2011-05-13 15:44:50 +00:00
|
|
|
.appendTo(self.$videoContainer);
|
|
|
|
self.video = self.$video[0];
|
2011-05-12 10:39:48 +00:00
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.poster) {
|
|
|
|
self.$poster = $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: self.options.poster
|
2011-05-12 20:02:22 +00:00
|
|
|
})
|
|
|
|
.css({
|
2011-05-14 19:32:49 +00:00
|
|
|
position: 'absolute'
|
2011-05-12 20:02:22 +00:00
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.appendTo(self.$videoContainer);
|
|
|
|
self.posterIsVisible = true;
|
2011-05-12 20:02:22 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
if (self.options.logo) {
|
|
|
|
self.$logo = $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: self.options.logo
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
cursor: self.options.logoLink ? 'pointer' : 'default',
|
|
|
|
opacity: 0.25,
|
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.appendTo(self.$videoContainer);
|
2011-05-13 15:44:50 +00:00
|
|
|
if (self.options.logoTitle) {
|
|
|
|
self.$logoTooltip = Ox.Tooltip({
|
|
|
|
title: self.options.logoTitle
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-12 10:51:17 +00:00
|
|
|
self.$loadingIcon = $('<img>')
|
|
|
|
.attr({
|
2011-05-14 19:32:49 +00:00
|
|
|
src: Ox.UI.getImagePath('symbolLoadingAnimated.svg')
|
|
|
|
.replace('/classic/', '/modern/')
|
2011-05-12 10:51:17 +00:00
|
|
|
})
|
|
|
|
.css({
|
2011-05-14 19:32:49 +00:00
|
|
|
position: 'absolute'
|
2011-05-12 10:51:17 +00:00
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.appendTo(self.$videoContainer);
|
2011-05-12 10:51:17 +00:00
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.showIcon || self.options.showIconOnLoad) {
|
|
|
|
self.$playIcon = $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: Ox.UI.getImagePath(
|
|
|
|
'symbol' + (self.options.paused ? 'Play' : 'Pause') + '.svg'
|
|
|
|
).replace('/classic/', '/modern/')
|
|
|
|
})
|
2011-05-13 15:44:50 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
border: '2px solid rgb(255, 255, 255)',
|
2011-05-14 19:32:49 +00:00
|
|
|
background: 'rgba(0, 0, 0, 0.5)',
|
2011-05-13 15:44:50 +00:00
|
|
|
opacity: 0
|
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.appendTo(self.$videoContainer);
|
2011-05-15 07:26:00 +00:00
|
|
|
if (self.options.showIcon) {
|
|
|
|
self.$playIcon.addClass('OxInterface');
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.showIconOnLoad) {
|
|
|
|
self.iconIsVisible = true;
|
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
2011-05-12 22:12:41 +00:00
|
|
|
|
2011-05-16 11:29:26 +00:00
|
|
|
if (self.options.subtitles.length || true) { // fixme
|
2011-05-13 15:44:50 +00:00
|
|
|
self.$subtitle = $('<div>')
|
|
|
|
//.addClass('OxSubtitle')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
textAlign: 'center',
|
|
|
|
textShadow: 'rgba(0, 0, 0, 1) 0 0 4px',
|
|
|
|
color: 'rgb(255, 255, 255)'
|
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.appendTo(self.$videoContainer);
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
2011-05-12 22:12:41 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
if (self.options.enableFind) {
|
|
|
|
|
|
|
|
self.$find = $('<div>')
|
2011-05-17 20:20:43 +00:00
|
|
|
.addClass('OxControls')
|
2011-05-13 15:44:50 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
2011-05-16 18:05:29 +00:00
|
|
|
right: 0,
|
|
|
|
top: self.options.controlsTop.length ? '16px' : 0,
|
|
|
|
borderBottomLeftRadius: '8px',
|
|
|
|
borderBottomRightRadius: '8px'
|
2011-05-13 15:44:50 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-moz-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-webkit-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.hide()
|
2011-05-13 15:44:50 +00:00
|
|
|
.appendTo(that.$element);
|
2011-05-16 11:29:26 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$results = $('<div>')
|
2011-05-16 11:29:26 +00:00
|
|
|
.css({
|
2011-05-16 18:05:29 +00:00
|
|
|
float: 'left',
|
|
|
|
width: '24px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center'
|
2011-05-16 11:29:26 +00:00
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.html('0')
|
|
|
|
.appendTo(self.$find);
|
2011-05-16 11:29:26 +00:00
|
|
|
|
|
|
|
self.$previousButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'arrowLeft',
|
|
|
|
tooltip: 'Previous [Shift+G]',
|
|
|
|
type: 'image'
|
|
|
|
})
|
2011-05-17 07:19:30 +00:00
|
|
|
.css({float: 'left'})
|
2011-05-16 11:29:26 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
goToNextResult(-1);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$find);
|
|
|
|
|
|
|
|
self.$nextButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'arrowRight',
|
|
|
|
tooltip: 'Next [G]',
|
|
|
|
type: 'image'
|
|
|
|
})
|
2011-05-17 07:19:30 +00:00
|
|
|
.css({float: 'left'})
|
2011-05-16 11:29:26 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
goToNextResult(1);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$find);
|
|
|
|
|
|
|
|
self.$findInput = Ox.Input({
|
2011-05-17 19:08:25 +00:00
|
|
|
changeOnKeypress: true,
|
2011-05-16 18:05:29 +00:00
|
|
|
value: self.options.find
|
2011-05-16 11:29:26 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
background: 'rgba(0, 0, 0, 0)',
|
|
|
|
MozBoxShadow: '0 0 0',
|
|
|
|
WebkitBoxShadow: '0 0 0'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-05-17 19:08:25 +00:00
|
|
|
blur: function() {
|
|
|
|
self.inputHasFocus = false;
|
|
|
|
},
|
2011-05-16 11:29:26 +00:00
|
|
|
focus: function() {
|
|
|
|
self.inputHasFocus = true;
|
|
|
|
},
|
2011-05-17 19:08:25 +00:00
|
|
|
change: function(data) {
|
|
|
|
submitFindInput(data.value, false);
|
2011-05-17 07:19:30 +00:00
|
|
|
},
|
2011-05-17 19:08:25 +00:00
|
|
|
submit: function(data) {
|
2011-05-17 07:19:30 +00:00
|
|
|
self.inputHasFocus = false;
|
2011-05-17 19:08:25 +00:00
|
|
|
submitFindInput(data.value, true);
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$find);
|
|
|
|
|
|
|
|
self.$findInput.children('input').css({
|
|
|
|
width: (self.positionWidth - 6) + 'px',
|
|
|
|
height: '16px',
|
|
|
|
padding: '0 3px 0 3px',
|
|
|
|
border: '0px',
|
|
|
|
borderRadius: '8px',
|
|
|
|
fontSize: '11px',
|
|
|
|
color: 'rgb(255, 255, 255)'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-moz-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-webkit-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
});
|
2011-05-16 18:05:29 +00:00
|
|
|
|
|
|
|
///*
|
2011-05-16 11:29:26 +00:00
|
|
|
self.$clearButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
2011-05-16 18:05:29 +00:00
|
|
|
title: 'delete',
|
2011-05-16 11:29:26 +00:00
|
|
|
tooltip: 'Clear',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$results.html('0');
|
2011-05-17 07:19:30 +00:00
|
|
|
self.$findInput.clearInput();
|
2011-05-16 11:29:26 +00:00
|
|
|
self.results = [];
|
|
|
|
self.$timeline && self.$timeline.options({
|
|
|
|
results: self.results
|
|
|
|
});
|
2011-05-16 18:05:29 +00:00
|
|
|
//setTimeout(self.$findInput.focusInput, 10);
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$find);
|
2011-05-16 18:05:29 +00:00
|
|
|
//*/
|
2011-05-17 07:05:21 +00:00
|
|
|
|
|
|
|
self.$hideFindButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'close',
|
|
|
|
tooltip: 'Hide',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent({
|
2011-05-17 07:43:20 +00:00
|
|
|
click: toggleFind
|
2011-05-17 07:05:21 +00:00
|
|
|
})
|
|
|
|
.appendTo(self.$find);
|
2011-05-16 11:29:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
['top', 'bottom'].forEach(function(edge) {
|
2011-05-12 10:39:48 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
var titlecase = Ox.toTitleCase(edge);
|
|
|
|
|
|
|
|
if (self.options['controls' + titlecase].length) {
|
|
|
|
|
|
|
|
self['$controls' + titlecase] = Ox.Bar({
|
2011-05-14 19:32:49 +00:00
|
|
|
size: self.barHeight
|
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.addClass('OxControls OxInterface')
|
2011-05-14 19:32:49 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
opacity: self.options.externalControls ? 1 : 0
|
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.css(edge, 0)
|
2011-05-14 19:32:49 +00:00
|
|
|
.appendTo(that.$element);
|
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
if (!self.options.externalControls) {
|
|
|
|
self['$controls' + titlecase].css({
|
|
|
|
backgroundImage: '-moz-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-webkit-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
});
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.options['controls' + titlecase].forEach(function(control) {
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
if (control == 'find') {
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$findButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
2011-05-17 07:05:21 +00:00
|
|
|
title: 'find',
|
|
|
|
tooltip: 'Find',
|
2011-05-16 18:05:29 +00:00
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', toggleFind)
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
|
|
|
|
|
|
|
} else if (control == 'fullscreen') {
|
|
|
|
|
|
|
|
self.$fullscreenButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: [
|
|
|
|
{id: 'grow', title: 'grow', selected: !self.options.fullscreen},
|
|
|
|
{id: 'shrink', title: 'shrink', selected: self.options.fullscreen}
|
|
|
|
],
|
|
|
|
tooltip: ['Enter Fullscreen', 'Exit Fullscreen'],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
toggleFullscreen('button');
|
2011-05-16 18:05:29 +00:00
|
|
|
})
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
|
|
|
|
|
|
|
} else if (control == 'mute') {
|
|
|
|
|
|
|
|
self.$muteButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: [
|
|
|
|
{id: 'mute', title: 'mute', selected: !self.options.muted},
|
|
|
|
{id: 'unmute', title: 'unmute', selected: self.options.muted}
|
|
|
|
],
|
|
|
|
tooltip: ['Mute', 'Unmute'],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
toggleMuted('button');
|
2011-05-16 18:05:29 +00:00
|
|
|
})
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
|
|
|
|
|
|
|
} else if (control == 'play') {
|
|
|
|
|
|
|
|
self.$playButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
// FIXME: this is retarded, fix Ox.Button
|
|
|
|
title: [
|
|
|
|
{id: 'play', title: 'play', selected: self.options.paused},
|
|
|
|
{id: 'pause', title: 'pause', selected: !self.options.paused}
|
|
|
|
],
|
|
|
|
tooltip: ['Play', 'Pause'],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused('button');
|
2011-05-16 18:05:29 +00:00
|
|
|
})
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (control == 'playInToOut') {
|
2011-05-12 10:39:48 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$playInToOutButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'playInToOut',
|
|
|
|
tooltip: 'Play In to Out',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', playInToOut)
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
2011-05-12 10:39:48 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (control == 'position') {
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.positionWidth = 48 +
|
|
|
|
!!self.options.showMilliseconds * 2
|
|
|
|
+ self.options.showMilliseconds * 6;
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$position = $('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: (self.positionWidth - 4) + 'px',
|
|
|
|
height: '12px',
|
|
|
|
padding: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center',
|
|
|
|
color: 'rgb(255, 255, 255)'
|
|
|
|
})
|
|
|
|
.html(formatPosition)
|
|
|
|
.bind({
|
|
|
|
click: function() {
|
|
|
|
if (!self.options.paused) {
|
2011-05-17 17:04:33 +00:00
|
|
|
self.playOnSubmit = true;
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
2011-05-17 17:04:33 +00:00
|
|
|
} else if (self.playOnLoad) {
|
|
|
|
// if clicked during resolution switch,
|
|
|
|
// don't play on load
|
|
|
|
self.playOnLoad = false;
|
|
|
|
self.playOnSubmit = true;
|
2011-05-16 18:05:29 +00:00
|
|
|
}
|
|
|
|
self.$position.hide();
|
|
|
|
self.$positionInput
|
|
|
|
.options({
|
|
|
|
value: formatPosition()
|
|
|
|
})
|
|
|
|
.show()
|
|
|
|
.focusInput(false);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self['$controls' + titlecase].$element);
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$positionInput = Ox.Input({
|
|
|
|
value: formatPosition(),
|
|
|
|
width: self.positionWidth
|
2011-05-14 19:32:49 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
2011-05-16 18:05:29 +00:00
|
|
|
background: 'rgba(0, 0, 0, 0)',
|
|
|
|
MozBoxShadow: '0 0 0',
|
|
|
|
WebkitBoxShadow: '0 0 0'
|
2011-05-14 19:32:49 +00:00
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.bindEvent({
|
|
|
|
focus: function() {
|
|
|
|
self.inputHasFocus = true;
|
|
|
|
},
|
|
|
|
blur: function() {
|
|
|
|
self.inputHasFocus = false;
|
|
|
|
submitPositionInput();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.hide()
|
|
|
|
.appendTo(self['$controls' + titlecase].$element);
|
|
|
|
|
|
|
|
self.$positionInput.children('input').css({
|
|
|
|
width: (self.positionWidth - 6) + 'px',
|
|
|
|
height: '16px',
|
|
|
|
padding: '0 3px 0 3px',
|
|
|
|
border: '0px',
|
|
|
|
borderRadius: '8px',
|
|
|
|
fontSize: '9px',
|
|
|
|
color: 'rgb(255, 255, 255)'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-moz-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-webkit-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
});
|
2011-05-17 16:02:25 +00:00
|
|
|
|
|
|
|
} else if (control == 'resolution') {
|
|
|
|
|
2011-05-17 18:44:53 +00:00
|
|
|
self.$resolutionButton = Ox.Element({
|
|
|
|
tooltip: 'Resolution'
|
|
|
|
})
|
2011-05-17 16:02:25 +00:00
|
|
|
.css({
|
|
|
|
float: 'left',
|
2011-05-17 16:18:44 +00:00
|
|
|
width: '32px',
|
2011-05-17 16:02:25 +00:00
|
|
|
height: '12px',
|
|
|
|
padding: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center',
|
|
|
|
color: 'rgb(255, 255, 255)',
|
|
|
|
cursor: 'default'
|
|
|
|
})
|
|
|
|
.html(self.options.resolution + 'p')
|
|
|
|
.bind({
|
|
|
|
click: function() {
|
|
|
|
self.$resolution.toggle();
|
|
|
|
}
|
|
|
|
})
|
2011-05-17 18:44:53 +00:00
|
|
|
.appendTo(self['$controls' + titlecase]);
|
2011-05-17 16:02:25 +00:00
|
|
|
|
|
|
|
self.$resolution = $('<div>')
|
2011-05-17 20:20:43 +00:00
|
|
|
.addClass('OxControls')
|
2011-05-17 16:02:25 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
bottom: '16px',
|
|
|
|
height: (self.resolutions.length * 16) + 'px',
|
|
|
|
background: 'transparent'
|
|
|
|
})
|
|
|
|
.bind({
|
|
|
|
click: function(e) {
|
|
|
|
var resolution = $(e.target).parent().data('resolution');
|
|
|
|
self.$resolution.hide();
|
|
|
|
if (resolution != self.options.resolution) {
|
|
|
|
self.$resolution.children().each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.children()[1].src =
|
|
|
|
$this.data('resolution') == resolution ?
|
|
|
|
Ox.UI.getImagePath('symbolCheck.svg') :
|
|
|
|
Ox.UI.PATH + 'png/transparent.png'
|
|
|
|
});
|
|
|
|
self.$resolutionButton.html(resolution + 'p');
|
|
|
|
self.options.resolution = resolution
|
|
|
|
setResolution();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.hide()
|
|
|
|
.appendTo(that.$element);
|
|
|
|
self.resolutions.forEach(function(resolution, i) {
|
|
|
|
var $item = $('<div>')
|
|
|
|
.css({
|
2011-05-17 16:18:44 +00:00
|
|
|
width: '52px',
|
2011-05-17 16:02:25 +00:00
|
|
|
height: '16px',
|
|
|
|
background: 'rgba(32, 32, 32, 0.5)'
|
|
|
|
})
|
|
|
|
.data({
|
|
|
|
resolution: resolution
|
|
|
|
})
|
|
|
|
.bind({
|
|
|
|
mouseenter: function() {
|
|
|
|
$(this)
|
|
|
|
.css({
|
2011-05-17 19:53:46 +00:00
|
|
|
backgroundImage: '-moz-linear-gradient(top, rgba(48, 48, 48, 0.5), rgba(16, 16, 16, 0.5))'
|
2011-05-17 16:02:25 +00:00
|
|
|
})
|
|
|
|
.css({
|
2011-05-17 19:53:46 +00:00
|
|
|
backgroundImage: '-webkit-linear-gradient(top, rgba(48, 48, 48, 0.5), rgba(16, 16, 16, 0.5))'
|
2011-05-17 16:02:25 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
$(this).css({
|
2011-05-17 17:04:33 +00:00
|
|
|
background: 'rgba(32, 32, 32, 0.5)'
|
2011-05-17 16:02:25 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$resolution);
|
|
|
|
if (i == 0) {
|
|
|
|
$item.css({
|
|
|
|
borderTopLeftRadius: '8px',
|
|
|
|
borderTopRightRadius: '8px'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
2011-05-17 16:18:44 +00:00
|
|
|
width: '36px',
|
2011-05-17 16:02:25 +00:00
|
|
|
height: '14px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'right',
|
|
|
|
cursor: 'default'
|
|
|
|
})
|
|
|
|
.html(resolution + 'p')
|
|
|
|
.appendTo($item);
|
|
|
|
$('<img>')
|
|
|
|
.attr({
|
|
|
|
src: resolution == self.options.resolution ?
|
|
|
|
Ox.UI.getImagePath('symbolCheck.svg') :
|
|
|
|
Ox.UI.PATH + 'png/transparent.png'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '9px',
|
|
|
|
height: '9px',
|
|
|
|
padding: '3px 3px 4px 4px'
|
|
|
|
})
|
|
|
|
.appendTo($item);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (control == 'scale') {
|
|
|
|
|
|
|
|
self.$scaleButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: [
|
|
|
|
{id: 'fill', title: 'fill', selected: !self.options.scaleToFill},
|
|
|
|
{id: 'fit', title: 'fit', selected: self.options.scaleToFill}
|
|
|
|
],
|
|
|
|
tooltip: ['Scale to Fill', 'Scale to Fit'],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', function() {
|
2011-05-17 18:01:40 +00:00
|
|
|
toggleScale('button');
|
2011-05-16 18:05:29 +00:00
|
|
|
})
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
|
|
|
|
|
|
|
} else if (control == 'size') {
|
|
|
|
|
|
|
|
self.$sizeButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: [
|
|
|
|
{id: 'grow', title: 'grow', selected: !self.options.sizeIsLarge},
|
|
|
|
{id: 'shrink', title: 'shrink', selected: self.options.sizeIsLarge}
|
|
|
|
],
|
|
|
|
tooltip: ['Larger', 'Smaller'],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent('click', toggleSize)
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
|
|
|
|
|
|
|
} else if (control == 'space') {
|
|
|
|
|
|
|
|
self['$space' + titlecase] = $('<div>')
|
|
|
|
.css({float: 'left'})
|
|
|
|
.html(' ') // fixme: ??
|
|
|
|
.appendTo(self['$controls' + titlecase].$element);
|
|
|
|
|
|
|
|
} else if (control == 'timeline') {
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (self.options.showProgress) {
|
|
|
|
self.$progress = $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: getProgressImageURL()
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
height: self.barHeight + 'px',
|
|
|
|
})
|
|
|
|
.appendTo(self.$timelineImages.$element);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (self.options.duration) {
|
|
|
|
self.$timeline = getTimeline()
|
|
|
|
} else {
|
|
|
|
self.$timeline = Ox.Element()
|
|
|
|
.css({
|
|
|
|
float: 'left'
|
|
|
|
})
|
|
|
|
.html(' ');
|
|
|
|
}
|
|
|
|
self.$timeline.appendTo(self['$controls' + titlecase]);
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (control == 'title') {
|
|
|
|
|
|
|
|
self.$title = $('<div>')
|
|
|
|
.addClass('OxInterface')
|
2011-05-16 11:29:26 +00:00
|
|
|
.css({
|
2011-05-16 18:05:29 +00:00
|
|
|
float: 'left',
|
|
|
|
paddingTop: '1px',
|
|
|
|
textAlign: 'center',
|
2011-05-17 07:05:21 +00:00
|
|
|
color: 'rgb(255, 255, 255)',
|
|
|
|
overflow: 'hidden',
|
|
|
|
textOverflow: 'ellipsis'
|
2011-05-16 11:29:26 +00:00
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.html(self.options.title)
|
|
|
|
.appendTo(self['$controls' + titlecase].$element);
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (control == 'volume') {
|
2011-05-14 19:32:49 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$volumeButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'mute',
|
|
|
|
tooltip: 'Volume',
|
|
|
|
type: 'image'
|
|
|
|
})
|
2011-05-14 19:32:49 +00:00
|
|
|
.css({float: 'left'})
|
2011-05-17 07:43:20 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: toggleVolume
|
2011-05-16 18:05:29 +00:00
|
|
|
})
|
|
|
|
.appendTo(self['$controls' + titlecase]);
|
2011-05-14 19:32:49 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
});
|
2011-05-14 19:32:49 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
});
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
if (self.options.enableVolume) {
|
2011-05-12 20:02:22 +00:00
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$volume = $('<div>')
|
2011-05-17 20:20:43 +00:00
|
|
|
.addClass('OxControls')
|
2011-05-16 18:05:29 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
bottom: self.options.controlsBottom.length ? '16px' : 0,
|
|
|
|
height: '16px',
|
|
|
|
borderTopLeftRadius: '8px',
|
|
|
|
borderTopRightRadius: '8px'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-moz-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-webkit-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
})
|
|
|
|
.hide()
|
|
|
|
.appendTo(that.$element);
|
|
|
|
|
2011-05-17 07:05:21 +00:00
|
|
|
self.$hideVolumeButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'close',
|
|
|
|
tooltip: 'Hide',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent({
|
2011-05-17 07:43:20 +00:00
|
|
|
click: toggleVolume
|
2011-05-17 07:05:21 +00:00
|
|
|
})
|
|
|
|
.appendTo(self.$volume);
|
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$muteButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: [
|
|
|
|
{id: 'mute', title: 'mute', selected: !self.options.muted},
|
|
|
|
{id: 'unmute', title: 'unmute', selected: self.options.muted}
|
|
|
|
],
|
|
|
|
tooltip: ['Mute', 'Unmute'],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
toggleMuted();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$volume);
|
|
|
|
|
|
|
|
self.$volumeInput = Ox.Range({
|
|
|
|
max: 1,
|
|
|
|
min: 0,
|
|
|
|
step: 0.001,
|
|
|
|
value: self.options.muted ? 0 : self.options.volume
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-05-17 10:34:55 +00:00
|
|
|
change: function(data) {
|
|
|
|
setVolume(data.value);
|
|
|
|
}
|
2011-05-16 18:05:29 +00:00
|
|
|
})
|
|
|
|
.appendTo(self.$volume);
|
|
|
|
|
|
|
|
self.$volumeInput.find('.OxTrack')
|
|
|
|
.css({
|
|
|
|
//border: '1px solid rgba(64, 64, 64, 1)'
|
|
|
|
padding: '1px',
|
|
|
|
border: 0
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-moz-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-webkit-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$volumeInput.find('.OxThumb')
|
|
|
|
.css({
|
|
|
|
//border: '1px solid rgba(64, 64, 64, 1)'
|
|
|
|
padding: '1px 7px 1px 7px',
|
|
|
|
border: 0
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-moz-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
backgroundImage: '-webkit-linear-gradient(top, rgba(64, 64, 64, 0.5), rgba(0, 0, 0, 0.5))'
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$volumeValue = $('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '24px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.html(self.options.muted ? 0 : Math.round(self.options.volume * 100))
|
|
|
|
.appendTo(self.$volume);
|
2011-05-12 20:02:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-17 08:58:03 +00:00
|
|
|
if (self.options.largeTimeline) {
|
|
|
|
|
|
|
|
if (self.options.duration) {
|
|
|
|
self.$largeTimeline = getLargeTimeline()
|
|
|
|
} else {
|
|
|
|
self.$largeTimeline = Ox.Element()
|
|
|
|
.css({
|
|
|
|
float: 'left'
|
|
|
|
})
|
|
|
|
.html(' ');
|
|
|
|
}
|
|
|
|
self.$largeTimeline.appendTo(that);
|
|
|
|
|
|
|
|
}
|
2011-05-16 18:05:29 +00:00
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
setSizes();
|
|
|
|
|
2011-05-15 16:18:58 +00:00
|
|
|
function clearInterfaceTimeout() {
|
|
|
|
clearTimeout(self.interfaceTimeout);
|
|
|
|
self.interfaceTimeout = 0;
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function ended() {
|
2011-05-14 19:32:49 +00:00
|
|
|
if (!self.options.paused) {
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
|
|
|
if (self.options.poster) {
|
|
|
|
self.$poster.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.posterIsVisible = true;
|
|
|
|
}
|
|
|
|
if (self.options.showIconOnLoad) {
|
|
|
|
self.$playIcon.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.iconIsVisible = true;
|
|
|
|
}
|
2011-05-12 20:02:22 +00:00
|
|
|
}
|
2011-05-12 10:39:48 +00:00
|
|
|
|
2011-05-17 19:08:25 +00:00
|
|
|
function find(query, hasPressedEnter) {
|
2011-05-16 18:05:29 +00:00
|
|
|
var results = [];
|
|
|
|
Ox.print(query)
|
|
|
|
if (query.length) {
|
|
|
|
query = query.toLowerCase();
|
|
|
|
results = Ox.map(self.options.subtitles, function(subtitle) {
|
|
|
|
return subtitle.text.toLowerCase().indexOf(query) > -1 ? {
|
|
|
|
'in': subtitle['in'],
|
|
|
|
out: subtitle.out
|
|
|
|
} : null;
|
|
|
|
});
|
2011-05-17 19:08:25 +00:00
|
|
|
if (results.length == 0 && hasPressedEnter) {
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$findInput.focusInput();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return results;
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
function formatPosition(position) {
|
|
|
|
position = Ox.isUndefined(position) ? self.options.position : position;
|
|
|
|
return Ox.formatDuration(position, self.options.showMilliseconds);
|
|
|
|
}
|
|
|
|
|
2011-05-15 08:35:00 +00:00
|
|
|
function getCSS(element) {
|
|
|
|
var css;
|
2011-05-16 18:05:29 +00:00
|
|
|
if (element == 'controlsTop' || element == 'controlsBottom') {
|
2011-05-15 08:35:00 +00:00
|
|
|
css = {
|
|
|
|
width: self.width + 'px'
|
|
|
|
};
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (element == 'find') {
|
|
|
|
css = {
|
|
|
|
width: Math.min(208, self.width) + 'px'
|
|
|
|
};
|
2011-05-15 08:35:00 +00:00
|
|
|
} else if (element == 'loadingIcon') {
|
|
|
|
css = {
|
|
|
|
left: self.iconLeft + 'px',
|
|
|
|
top: self.iconTop + 'px',
|
|
|
|
width: self.iconSize + 'px',
|
|
|
|
height: self.iconSize + 'px'
|
|
|
|
};
|
|
|
|
} else if (element == 'logo') {
|
2011-05-15 16:18:58 +00:00
|
|
|
var logoHeight = Math.round(self.height / 10),
|
|
|
|
logoMargin = Math.round(self.height / 20);
|
2011-05-15 08:35:00 +00:00
|
|
|
css = {
|
2011-05-15 16:18:58 +00:00
|
|
|
left: logoMargin + 'px',
|
2011-05-16 18:05:29 +00:00
|
|
|
top: logoMargin + (self.controlsTopAreVisible ? 16 : 0) + 'px',
|
2011-05-15 08:35:00 +00:00
|
|
|
height: logoHeight + 'px',
|
|
|
|
};
|
|
|
|
} else if (element == 'player') {
|
2011-05-17 07:43:20 +00:00
|
|
|
var height = self.options.fullscreen ? window.innerHeight : self.height;
|
|
|
|
if (self.options.externalControls) {
|
|
|
|
height += (
|
|
|
|
!!self.options.controlsTop.length +
|
|
|
|
!!self.options.controlsBottom.length
|
|
|
|
) * self.barHeight;
|
|
|
|
}
|
|
|
|
if (self.options.largeTimeline) {
|
|
|
|
height += 64;
|
|
|
|
}
|
2011-05-15 08:35:00 +00:00
|
|
|
css = Ox.extend({
|
|
|
|
width: self.width + 'px',
|
2011-05-17 07:43:20 +00:00
|
|
|
height: height + 'px'
|
2011-05-15 08:35:00 +00:00
|
|
|
}, self.options.fullscreen ? {
|
|
|
|
left: 0,
|
|
|
|
top: 0
|
|
|
|
} : {}, self.exitFullscreen ? {
|
|
|
|
left: self.absoluteOffset.left,
|
|
|
|
top: self.absoluteOffset.top
|
|
|
|
} : {});
|
|
|
|
} else if (element == 'playIcon') {
|
|
|
|
var playIconPadding = Math.round(self.iconSize * 1/8),
|
|
|
|
playIconSize = self.iconSize - 2 * playIconPadding - 4;
|
|
|
|
css = {
|
|
|
|
left: self.iconLeft + 'px',
|
|
|
|
top: self.iconTop + 'px',
|
|
|
|
width: playIconSize + 'px',
|
|
|
|
height: playIconSize + 'px',
|
|
|
|
padding: playIconPadding + 'px',
|
|
|
|
borderRadius: Math.round(self.iconSize / 2) + 'px'
|
|
|
|
};
|
|
|
|
} else if (element == 'poster' || element == 'video') {
|
|
|
|
var playerWidth = self.width,
|
|
|
|
playerHeight = self.height,
|
|
|
|
playerRatio = playerWidth / playerHeight,
|
|
|
|
videoWidth = self.video.videoWidth,
|
|
|
|
videoHeight = self.video.videoHeight,
|
|
|
|
videoRatio = videoWidth / videoHeight,
|
|
|
|
videoIsWider = videoRatio > playerRatio,
|
|
|
|
width, height;
|
|
|
|
if (self.options.scaleToFill) {
|
|
|
|
width = videoIsWider ? playerHeight * videoRatio : playerWidth;
|
|
|
|
height = videoIsWider ? playerHeight : playerWidth / videoRatio;
|
|
|
|
} else {
|
|
|
|
width = videoIsWider ? playerWidth : playerHeight * videoRatio;
|
|
|
|
height = videoIsWider ? playerWidth / videoRatio : playerHeight;
|
|
|
|
}
|
|
|
|
width = Math.round(width);
|
|
|
|
height = Math.round(height);
|
|
|
|
css = {
|
|
|
|
width: width + 'px',
|
|
|
|
height: height + 'px',
|
|
|
|
marginLeft: parseInt((playerWidth - width) / 2),
|
|
|
|
marginTop: parseInt((playerHeight - height) / 2)
|
|
|
|
};
|
|
|
|
} else if (element == 'progress') {
|
|
|
|
css = {
|
|
|
|
width: self.timelineImageWidth + 'px',
|
|
|
|
marginLeft: -self.timelineImageWidth + 'px'
|
|
|
|
};
|
|
|
|
} else if (element == 'subtitle') {
|
|
|
|
css = {
|
2011-05-16 18:05:29 +00:00
|
|
|
bottom: (parseInt(self.height / 16) + !!self.controlsBottomAreVisible * 16) + 'px',
|
2011-05-15 08:35:00 +00:00
|
|
|
width: self.width + 'px',
|
|
|
|
fontSize: parseInt(self.height / 20) + 'px',
|
|
|
|
WebkitTextStroke: (self.height / 1000) + 'px rgb(0, 0, 0)'
|
|
|
|
};
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (element == 'spaceBottom' || element == 'timeline') {
|
2011-05-15 08:35:00 +00:00
|
|
|
css = {
|
|
|
|
width: self.timelineWidth + 'px'
|
|
|
|
};
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (element == 'spaceTop' || element == 'title') {
|
|
|
|
css = {
|
|
|
|
width: getTitleWidth() + 'px'
|
|
|
|
};
|
2011-05-15 08:35:00 +00:00
|
|
|
} else if (element == 'videoContainer') {
|
|
|
|
css = {
|
|
|
|
width: self.width + 'px',
|
|
|
|
height: self.height + 'px'
|
|
|
|
};
|
2011-05-16 18:05:29 +00:00
|
|
|
} else if (element == 'volume') {
|
|
|
|
css = {
|
2011-05-17 07:05:21 +00:00
|
|
|
width: Math.min(184, self.width)
|
2011-05-16 18:05:29 +00:00
|
|
|
};
|
2011-05-15 08:35:00 +00:00
|
|
|
}
|
|
|
|
return css;
|
|
|
|
}
|
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
function getPosition(e) {
|
|
|
|
// fixme: no offsetX in firefox???
|
|
|
|
if ($.browser.mozilla) {
|
|
|
|
//Ox.print(e, e.layerX - 56)
|
|
|
|
return Ox.limit(
|
|
|
|
(e.layerX - 48 - self.barHeight / 2) / self.timelineImageWidth * self.video.duration,
|
|
|
|
0, self.video.duration
|
|
|
|
);
|
2011-05-12 10:39:48 +00:00
|
|
|
} else {
|
2011-05-14 19:32:49 +00:00
|
|
|
/*Ox.print(e.offsetX, Ox.limit(
|
|
|
|
(e.offsetX - self.barHeight / 2) / self.timelineImageWidth * self.video.duration,
|
|
|
|
0, self.video.duration
|
|
|
|
))*/
|
|
|
|
return Ox.limit(
|
|
|
|
(e.offsetX - self.barHeight / 2) / self.timelineImageWidth * self.video.duration,
|
|
|
|
0, self.video.duration
|
|
|
|
);
|
2011-05-12 10:39:48 +00:00
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getProgressImageURL() {
|
|
|
|
Ox.print('---', self.timelineImageWidth)
|
|
|
|
if (!self.timelineImageWidth) return;
|
|
|
|
var width = self.timelineImageWidth,
|
2011-05-13 15:44:50 +00:00
|
|
|
height = self.barHeight,
|
2011-05-14 19:32:49 +00:00
|
|
|
canvas = $('<canvas>')
|
2011-05-12 10:39:48 +00:00
|
|
|
.attr({
|
|
|
|
width: width,
|
2011-05-14 19:32:49 +00:00
|
|
|
height: height
|
|
|
|
})[0],
|
|
|
|
context = canvas.getContext('2d'),
|
|
|
|
imageData, data;
|
2011-05-12 10:39:48 +00:00
|
|
|
context.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
|
|
|
context.fillRect(0, 0, width, height);
|
2011-05-14 19:32:49 +00:00
|
|
|
imageData = context.getImageData(0, 0, width, height),
|
|
|
|
data = imageData.data;
|
2011-05-12 10:39:48 +00:00
|
|
|
self.buffered.forEach(function(range) {
|
2011-05-13 15:44:50 +00:00
|
|
|
var left = Math.round(range[0] * width / self.video.duration),
|
|
|
|
right = Math.round(range[1] * width / self.video.duration);
|
2011-05-12 10:39:48 +00:00
|
|
|
Ox.loop(left, right, function(x) {
|
|
|
|
Ox.loop(height, function(y) {
|
|
|
|
index = x * 4 + y * 4 * width;
|
|
|
|
data[index + 3] = 0;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
context.putImageData(imageData, 0, 0);
|
|
|
|
return canvas.toDataURL();
|
|
|
|
}
|
|
|
|
|
2011-05-12 22:12:41 +00:00
|
|
|
function getSubtitle() {
|
|
|
|
var subtitle = '';
|
|
|
|
Ox.forEach(self.options.subtitles, function(v) {
|
|
|
|
if (
|
|
|
|
v['in'] <= self.options.position &&
|
|
|
|
v.out > self.options.position
|
|
|
|
) {
|
2011-05-17 19:30:49 +00:00
|
|
|
subtitle = v.text;
|
2011-05-12 22:12:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return subtitle;
|
|
|
|
}
|
|
|
|
|
2011-05-17 08:58:03 +00:00
|
|
|
function getLargeTimeline() {
|
|
|
|
var $timeline = Ox.LargeVideoTimeline({
|
|
|
|
duration: self.options.duration,
|
|
|
|
find: self.options.find,
|
|
|
|
getImageURL: self.options.largeTimeline,
|
|
|
|
'in': self.options['in'],
|
|
|
|
out: self.options.out,
|
|
|
|
position: self.options.position,
|
|
|
|
subtitles: self.options.subtitles,
|
|
|
|
type: 'player',
|
|
|
|
width: self.options.width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: '12px',
|
|
|
|
marginLeft: 0,
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
position: function(data) {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(data.position, 'largeTimeline');
|
2011-05-17 08:58:03 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return $timeline;
|
|
|
|
}
|
|
|
|
|
2011-05-16 11:29:26 +00:00
|
|
|
function getTimeline() {
|
|
|
|
var $timeline = Ox.SmallVideoTimeline({
|
|
|
|
_offset: getTimelineLeft(),
|
|
|
|
duration: self.options.duration,
|
2011-05-17 18:04:26 +00:00
|
|
|
find: self.options.find,
|
2011-05-16 11:29:26 +00:00
|
|
|
'in': self.options['in'],
|
|
|
|
out: self.options.out,
|
|
|
|
paused: self.options.paused,
|
|
|
|
results: self.results,
|
|
|
|
showMilliseconds: self.options.showMilliseconds,
|
|
|
|
subtitles: self.options.subtitles,
|
2011-05-17 09:43:54 +00:00
|
|
|
timeline: self.options.timeline,
|
2011-05-16 11:29:26 +00:00
|
|
|
type: 'player',
|
|
|
|
width: getTimelineWidth()
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left'
|
|
|
|
})
|
2011-05-16 18:05:29 +00:00
|
|
|
.css({
|
|
|
|
background: '-moz-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
background: '-webkit-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(64, 64, 64, 0.5))'
|
|
|
|
})
|
2011-05-16 11:29:26 +00:00
|
|
|
.bindEvent({
|
|
|
|
position: function(data) {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(data.position, 'timeline');
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
//Ox.print('??', $timeline.find('.OxInterface'))
|
|
|
|
$timeline.children().css({
|
|
|
|
marginLeft: getTimelineLeft() + 'px'
|
|
|
|
});
|
|
|
|
$timeline.find('.OxInterface').css({
|
|
|
|
marginLeft: getTimelineLeft() + 'px'
|
|
|
|
});
|
|
|
|
return $timeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTimelineLeft() {
|
|
|
|
var left = 0;
|
2011-05-16 18:05:29 +00:00
|
|
|
Ox.forEach(self.options.controlsBottom, function(control) {
|
2011-05-16 11:29:26 +00:00
|
|
|
if (control == 'timeline') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
left += control == 'position' ? self.positionWidth : 16
|
|
|
|
});
|
|
|
|
return left;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTimelineWidth() {
|
|
|
|
return (self.options.fullscreen ? window.innerWidth : self.options.width) -
|
2011-05-16 18:05:29 +00:00
|
|
|
self.options.controlsBottom.reduce(function(prev, curr) {
|
2011-05-16 11:29:26 +00:00
|
|
|
return prev + (
|
|
|
|
curr == 'timeline' || curr == 'space' ? 0 :
|
2011-05-17 16:02:25 +00:00
|
|
|
curr == 'position' ? self.positionWidth :
|
2011-05-17 16:18:44 +00:00
|
|
|
curr == 'resolution' ? 36 : 16
|
2011-05-16 11:29:26 +00:00
|
|
|
);
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
function getTitleWidth() {
|
|
|
|
return (self.options.fullscreen ? window.innerWidth : self.options.width) -
|
|
|
|
self.options.controlsTop.reduce(function(prev, curr) {
|
|
|
|
return prev + (
|
|
|
|
curr == 'title' || curr == 'space' ? 0 : 16
|
|
|
|
);
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getVolumeImageURL() {
|
|
|
|
var symbol;
|
|
|
|
if (self.options.muted || self.options.volume == 0) {
|
|
|
|
symbol = 'unmute';
|
|
|
|
} else if (self.options.volume < 1/3) {
|
|
|
|
symbol = 'VolumeUp';
|
|
|
|
} else if (self.options.volume < 2/3) {
|
|
|
|
symbol = 'VolumeDown';
|
|
|
|
} else {
|
|
|
|
symbol = 'mute';
|
|
|
|
}
|
|
|
|
return Ox.UI.getImagePath('symbol' + symbol + '.svg').replace('/classic/', '/modern/');
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function hideInterface() {
|
2011-05-15 16:18:58 +00:00
|
|
|
Ox.print('hideInterface');
|
2011-05-17 20:20:43 +00:00
|
|
|
clearTimeout(self.interfaceTimeout);
|
2011-05-15 16:18:58 +00:00
|
|
|
self.interfaceTimeout = setTimeout(function() {
|
|
|
|
if (!self.exitFullscreen && !self.inputHasFocus && !self.mouseIsInControls) {
|
2011-05-17 20:20:43 +00:00
|
|
|
self.interfaceIsVisible = false;
|
2011-05-16 18:05:29 +00:00
|
|
|
self.controlsTopAreVisible = false;
|
|
|
|
self.controlsBottomAreVisible = false;
|
|
|
|
self.$controlsTop && self.$controlsTop.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
|
|
|
self.$controlsBottom && self.$controlsBottom.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
|
|
|
self.$find && self.$find.is(':visible') && self.$find.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
|
|
|
self.$volume && self.$volume.is(':visible') && self.$volume.animate({
|
2011-05-12 20:02:22 +00:00
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
2011-05-17 16:02:25 +00:00
|
|
|
self.$resolution && self.$resolution.is(':visible') && self.$resolution.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
2011-05-13 15:44:50 +00:00
|
|
|
self.$logo && self.$logo.animate({
|
2011-05-15 16:18:58 +00:00
|
|
|
top: getCSS('logo').top,
|
2011-05-13 15:44:50 +00:00
|
|
|
opacity: 0.25
|
|
|
|
}, 250, function() {
|
|
|
|
self.options.logoLink && self.$logo.unbind('click');
|
|
|
|
self.options.logoTitle &&
|
|
|
|
self.$logo.unbind('mouseenter').unbind('mouseleave');
|
|
|
|
});
|
2011-05-14 19:32:49 +00:00
|
|
|
self.$subtitle && self.$subtitle.animate({
|
2011-05-15 16:18:58 +00:00
|
|
|
bottom: getCSS('subtitle').bottom,
|
|
|
|
}, 250);
|
|
|
|
}
|
|
|
|
}, self.options.fullscreen ? 2500 : 1000);
|
2011-05-12 10:39:48 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function hideLoadingIcon() {
|
|
|
|
self.$loadingIcon.hide().attr({
|
|
|
|
src: Ox.UI.getImagePath('symbolLoading.svg')
|
|
|
|
.replace('/classic/', '/modern/')
|
|
|
|
});
|
2011-05-12 10:51:17 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function loadedmetadata() {
|
|
|
|
|
2011-05-17 16:02:25 +00:00
|
|
|
Ox.print('LOADEDMETADATA')
|
|
|
|
|
2011-05-16 11:29:26 +00:00
|
|
|
var hadDuration = !!self.options.duration;
|
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
self.loaded = true;
|
|
|
|
self.out = self.options.playInToOut &&
|
|
|
|
self.options.out < self.video.duration ?
|
|
|
|
self.options.out : self.video.duration;
|
|
|
|
self.options.duration = self.out - self['in'];
|
2011-05-15 07:26:00 +00:00
|
|
|
self.$video.css(getCSS('video'));
|
2011-05-17 16:18:44 +00:00
|
|
|
self.video.currentTime = self.options.position;
|
2011-05-17 18:01:40 +00:00
|
|
|
self.playOnLoad && self.options.paused && togglePaused();
|
2011-05-17 16:18:44 +00:00
|
|
|
//self.$poster && self.$poster.css(getCSS('poster'));
|
2011-05-13 15:44:50 +00:00
|
|
|
|
2011-05-12 11:15:32 +00:00
|
|
|
hideLoadingIcon();
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.showIcon || self.options.showIconOnLoad) {
|
|
|
|
//!self.options.keepIconVisible && self.$playIcon.addClass('OxInterface');
|
|
|
|
if (self.options.showIconOnLoad) {
|
|
|
|
self.$playIcon.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
2011-05-12 11:15:32 +00:00
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 08:58:03 +00:00
|
|
|
if (!hadDuration) {
|
|
|
|
self.$timeline && self.$timeline.replaceWith(
|
|
|
|
self.$timeline = getTimeline()
|
|
|
|
);
|
|
|
|
self.$largeTimeline && self.$largeTimeline.replaceWith(
|
|
|
|
self.$largeTimeline = getLargeTimeline()
|
|
|
|
);
|
2011-05-12 11:15:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 11:29:26 +00:00
|
|
|
if (self.options.enableKeyboard && self.options.focus == 'load') {
|
|
|
|
that.gainFocus();
|
|
|
|
}
|
2011-05-12 11:15:32 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function parsePositionInput(str) {
|
2011-05-14 19:32:49 +00:00
|
|
|
var split = str.split(':').reverse();
|
2011-05-13 15:44:50 +00:00
|
|
|
while (split.length > 3) {
|
|
|
|
split.pop();
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
return split.reduce(function(prev, curr, i) {
|
2011-05-13 15:44:50 +00:00
|
|
|
return prev + (parseFloat(curr) || 0) * Math.pow(60, i);
|
2011-05-14 19:32:49 +00:00
|
|
|
}, 0);
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function playing() {
|
2011-05-14 19:32:49 +00:00
|
|
|
self.options.position = self.video.currentTime;
|
2011-05-13 15:44:50 +00:00
|
|
|
if (
|
|
|
|
(self.options.playInToOut || self.playInToOut) &&
|
|
|
|
self.options.position >= self.options.out
|
|
|
|
) {
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
|
|
|
setPosition(self.options.out, 'video');
|
2011-05-14 19:32:49 +00:00
|
|
|
//ended();
|
|
|
|
self.playInToOut = false;
|
2011-05-13 15:44:50 +00:00
|
|
|
} else {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(self.options.position, 'video');
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
2011-05-15 16:18:58 +00:00
|
|
|
that.triggerEvent('position', {
|
|
|
|
position: self.options.position
|
|
|
|
});
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
function playInToOut() {
|
2011-05-17 20:20:43 +00:00
|
|
|
if (self.options.out > self.options['in']) {
|
|
|
|
self.playInToOut = true;
|
|
|
|
setPosition(self.options['in']);
|
|
|
|
if (self.options.paused) {
|
|
|
|
togglePaused();
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function progress() {
|
|
|
|
var buffered = self.video.buffered;
|
|
|
|
for (var i = 0; i < buffered.length; i++) {
|
|
|
|
self.buffered[i] = [buffered.start(i), buffered.end(i)];
|
|
|
|
// fixme: firefox weirdness
|
|
|
|
if (self.buffered[i][0] > self.buffered[i][1]) {
|
|
|
|
self.buffered[i][0] = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
self.$progress.attr({
|
|
|
|
src: getProgressImageURL()
|
|
|
|
});
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function seeked() {
|
2011-05-17 19:53:46 +00:00
|
|
|
Ox.print('XX seeked')
|
2011-05-15 07:26:00 +00:00
|
|
|
clearTimeout(self.seekTimeout);
|
2011-05-17 19:53:46 +00:00
|
|
|
self.seekTimeout = 0;
|
|
|
|
Ox.print('XX hide')
|
2011-05-13 15:44:50 +00:00
|
|
|
hideLoadingIcon();
|
2011-05-15 07:26:00 +00:00
|
|
|
self.$playIcon && self.$playIcon.show();
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function seeking() {
|
2011-05-17 19:53:46 +00:00
|
|
|
Ox.print('XX seeking')
|
|
|
|
if (!self.seekTimeout) {
|
|
|
|
self.seekTimeout = setTimeout(function() {
|
|
|
|
self.$playIcon && self.$playIcon.hide();
|
|
|
|
Ox.print('XX show')
|
|
|
|
showLoadingIcon();
|
|
|
|
}, 250);
|
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:01:40 +00:00
|
|
|
function setPosition(position, from) {
|
2011-05-15 08:35:00 +00:00
|
|
|
position = Ox.limit(position, self['in'], self['out']);
|
2011-05-14 19:32:49 +00:00
|
|
|
self.options.position = Math.round(
|
2011-05-15 08:35:00 +00:00
|
|
|
position * self.options.fps
|
2011-05-14 19:32:49 +00:00
|
|
|
) / self.options.fps;
|
2011-05-17 18:01:40 +00:00
|
|
|
if (self.loaded && from != 'video') {
|
2011-05-15 08:35:00 +00:00
|
|
|
self.video.currentTime = self.options.position;
|
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.iconIsVisible) {
|
|
|
|
self.$playIcon.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
|
|
|
self.iconIsVisible = false;
|
|
|
|
}
|
|
|
|
if (self.posterIsVisible) {
|
|
|
|
self.$poster.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 250);
|
|
|
|
self.posterIsVisible = false;
|
|
|
|
}
|
|
|
|
self.$subtitle && setSubtitle();
|
2011-05-17 18:01:40 +00:00
|
|
|
self.$timeline /*&& from != 'timeline'*/ && self.$timeline.options({
|
2011-05-16 11:29:26 +00:00
|
|
|
position: self.options.position
|
|
|
|
});
|
2011-05-17 18:01:40 +00:00
|
|
|
self.$largeTimeline && from != 'largeTimeline' && self.$largeTimeline.options({
|
2011-05-17 08:58:03 +00:00
|
|
|
position: self.options.position
|
|
|
|
});
|
2011-05-14 19:32:49 +00:00
|
|
|
self.$position && self.$position.html(formatPosition());
|
|
|
|
}
|
|
|
|
|
2011-05-17 16:02:25 +00:00
|
|
|
function setResolution() {
|
2011-05-17 16:18:44 +00:00
|
|
|
if (!self.options.paused) {
|
|
|
|
self.playOnLoad = true;
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
2011-05-17 16:18:44 +00:00
|
|
|
}
|
2011-05-17 16:02:25 +00:00
|
|
|
self.loaded = false;
|
|
|
|
showLoadingIcon();
|
|
|
|
self.video.src = self.options.video[self.options.resolution];
|
|
|
|
}
|
|
|
|
|
2011-05-15 07:26:00 +00:00
|
|
|
function setSizes(callback) {
|
|
|
|
var ms = callback ? 250 : 0;
|
|
|
|
self.width = self.options.fullscreen ? window.innerWidth : self.options.width;
|
|
|
|
self.height = self.options.fullscreen ? window.innerHeight : self.options.height;
|
|
|
|
self.iconSize = Math.max(Math.round(self.height / 10), 16),
|
|
|
|
self.iconLeft = parseInt((self.width - self.iconSize) / 2),
|
|
|
|
self.iconTop = parseInt((self.height - self.iconSize) / 2);
|
2011-05-16 18:17:22 +00:00
|
|
|
if (self.$timeline || self.$spaceBottom) {
|
2011-05-17 16:02:25 +00:00
|
|
|
self.timelineWidth = getTimelineWidth();
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.$timeline) {
|
2011-05-15 07:26:00 +00:00
|
|
|
self.timelineImageWidth = self.timelineWidth - self.barHeight;
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-15 07:26:00 +00:00
|
|
|
that.animate(getCSS('player'), ms, callback);
|
|
|
|
self.$videoContainer.animate(getCSS('videoContainer'), ms);
|
|
|
|
self.loaded && self.$video.animate(getCSS('video'), ms);
|
|
|
|
self.$poster && self.$poster.animate(getCSS('poster'), ms);
|
|
|
|
self.$logo && self.$logo.animate(getCSS('logo'), ms);
|
|
|
|
self.$loadingIcon.animate(getCSS('loadingIcon'), ms);
|
|
|
|
self.$playIcon && self.$playIcon.animate(getCSS('playIcon'), ms);
|
|
|
|
self.$subtitle && self.$subtitle.animate(getCSS('subtitle'), ms);
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$controlsTop && self.$controlsTop.animate(getCSS('controlsTop'), ms);
|
2011-05-15 16:18:58 +00:00
|
|
|
self.$title && self.$title.animate(getCSS('title'), ms);
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$spaceTop && self.$spaceTop.animate(getCSS('spaceTop'), ms);
|
|
|
|
self.$controlsBottom && self.$controlsBottom.animate(getCSS('controlsBottom'), ms);
|
2011-05-15 07:26:00 +00:00
|
|
|
if (self.$timeline) {
|
2011-05-16 11:29:26 +00:00
|
|
|
self.$timeline.animate(getCSS('timeline'), ms, function() {
|
|
|
|
self.$timeline.options({
|
|
|
|
width: self.timelineWidth
|
|
|
|
})
|
|
|
|
});
|
2011-05-15 07:26:00 +00:00
|
|
|
}
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$spaceBottom && self.$spaceBottom.animate(getCSS('spaceBottom'), ms);
|
|
|
|
if (self.$find) {
|
|
|
|
self.$find.animate(getCSS('find'), ms);
|
|
|
|
self.$findInput.options({
|
|
|
|
width: Math.min(128, self.width - 80)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (self.$volume) {
|
|
|
|
self.$volume.animate(getCSS('volume'), ms);
|
|
|
|
self.$volumeInput.options({
|
2011-05-17 08:58:03 +00:00
|
|
|
size: Math.min(128, self.width - 56) // fixme: should be width in Ox.Range
|
2011-05-16 18:05:29 +00:00
|
|
|
});
|
|
|
|
}
|
2011-05-17 08:58:03 +00:00
|
|
|
self.$largeTimeline && self.$largeTimeline.options({
|
|
|
|
width: self.width
|
|
|
|
});
|
2011-05-12 11:15:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-12 22:12:41 +00:00
|
|
|
function setSubtitle() {
|
|
|
|
var subtitle = getSubtitle();
|
|
|
|
if (subtitle != self.subtitle) {
|
|
|
|
self.subtitle = subtitle;
|
2011-05-17 19:30:49 +00:00
|
|
|
setSubtitleText();
|
2011-05-12 22:12:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-17 19:30:49 +00:00
|
|
|
function setSubtitleText() {
|
|
|
|
Ox.print('setSubTx', self.subtitle, self.options.find)
|
|
|
|
self.$subtitle.html(
|
|
|
|
Ox.highlight(self.subtitle, self.options.find, 'OxHighlight')
|
|
|
|
.replace(/\n/g, '<br/>')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-05-17 10:34:55 +00:00
|
|
|
function changeVolumeBy(num) {
|
|
|
|
self.options.volume = Ox.limit(self.options.volume + num, 0, 1);
|
|
|
|
setVolume(self.options.volume);
|
|
|
|
self.$volumeInput && self.$volumeInput.options({
|
|
|
|
value: self.options.volume
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setVolume(volume) {
|
|
|
|
self.options.volume = volume;
|
2011-05-17 07:05:21 +00:00
|
|
|
if (!!self.options.volume == self.options.muted) {
|
|
|
|
self.options.muted = !self.options.muted;
|
|
|
|
self.video.muted = self.options.muted;
|
|
|
|
self.$muteButton.toggleTitle();
|
|
|
|
}
|
|
|
|
self.video.volume = self.options.volume;
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$volumeButton.attr({
|
|
|
|
src: getVolumeImageURL()
|
|
|
|
});
|
|
|
|
self.$volumeValue.html(self.options.muted ? 0 : Math.round(self.options.volume * 100));
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function showInterface() {
|
2011-05-15 16:18:58 +00:00
|
|
|
Ox.print('showInterface');
|
|
|
|
clearTimeout(self.interfaceTimeout);
|
2011-05-17 20:20:43 +00:00
|
|
|
if (!self.interfaceIsVisible) {
|
|
|
|
self.interfaceIsVisible = true;
|
|
|
|
if (self.$controlsTop) {
|
|
|
|
self.controlsTopAreVisible = true;
|
|
|
|
}
|
|
|
|
if (self.$controlsBottom) {
|
|
|
|
self.controlsBottomAreVisible = true;
|
|
|
|
}
|
|
|
|
self.$controlsTop && self.$controlsTop.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.$controlsBottom && self.$controlsBottom.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.$find && self.$find.is(':visible') && self.$find.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.$volume && self.$volume.is(':visible') && self.$volume.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.$resolution && self.$resolution.is(':visible') && self.$resolution.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
self.$logo && self.$logo.animate({
|
|
|
|
top: getCSS('logo').top,
|
|
|
|
opacity: 0.5
|
|
|
|
}, 250, function() {
|
|
|
|
self.options.logoLink && self.$logo
|
|
|
|
.bind({
|
|
|
|
click: function() {
|
|
|
|
document.location.href = self.options.logoLink;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
self.options.logoTitle && self.$logo
|
|
|
|
.bind({
|
|
|
|
mouseenter: function(e) {
|
|
|
|
self.$logoTooltip.show(e);
|
|
|
|
},
|
|
|
|
mouseleave: self.$logoTooltip.hide
|
|
|
|
});
|
|
|
|
});
|
|
|
|
self.$subtitle && self.$subtitle.animate({
|
|
|
|
bottom: getCSS('subtitle').bottom,
|
|
|
|
}, 250);
|
2011-05-15 16:18:58 +00:00
|
|
|
}
|
2011-05-12 10:51:17 +00:00
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
|
|
|
|
function showLoadingIcon() {
|
|
|
|
self.$loadingIcon.attr({
|
|
|
|
src: Ox.UI.getImagePath('symbolLoadingAnimated.svg')
|
|
|
|
.replace('/classic/', '/modern/')
|
2011-05-14 19:32:49 +00:00
|
|
|
}).show();
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 19:08:25 +00:00
|
|
|
function submitFindInput(value, hasPressedEnter) {
|
|
|
|
self.options.find = value;
|
|
|
|
self.results = find(self.options.find, hasPressedEnter);
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$results.html(self.results.length);
|
2011-05-17 19:30:49 +00:00
|
|
|
self.subtitle && setSubtitleText();
|
2011-05-16 11:29:26 +00:00
|
|
|
self.$timeline && self.$timeline.options({
|
2011-05-17 18:04:26 +00:00
|
|
|
find: self.options.find,
|
2011-05-16 11:29:26 +00:00
|
|
|
results: self.results
|
|
|
|
});
|
2011-05-17 19:08:25 +00:00
|
|
|
if (hasPressedEnter && self.results.length) {
|
2011-05-16 18:05:29 +00:00
|
|
|
goToNextResult(1);
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function goToNextResult(direction) {
|
|
|
|
var found = false,
|
|
|
|
position = 0;
|
|
|
|
direction == -1 && self.results.reverse();
|
|
|
|
Ox.forEach(self.results, function(v) {
|
|
|
|
if (direction == 1 ? v['in'] > self.options.position : v['out'] < self.options.position) {
|
|
|
|
position = v['in'];
|
|
|
|
found = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
direction == -1 && self.results.reverse();
|
|
|
|
if (!found) {
|
|
|
|
position = self.results[direction == 1 ? 0 : self.results.length - 1]['in'];
|
|
|
|
}
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(position + self.secondsPerFrame);
|
2011-05-16 11:29:26 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
function submitPositionInput() {
|
|
|
|
self.$positionInput.hide();
|
|
|
|
self.$position.html('').show();
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(parsePositionInput(self.$positionInput.options('value')));
|
2011-05-17 17:04:33 +00:00
|
|
|
if (self.playOnSubmit) {
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
2011-05-13 15:44:50 +00:00
|
|
|
self.video.play();
|
2011-05-17 17:04:33 +00:00
|
|
|
self.playOnSubmit = false;
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
2011-05-15 16:18:58 +00:00
|
|
|
if (self.focus == 'mouseenter' && !self.mouseHasLeft) {
|
|
|
|
that.gainFocus();
|
|
|
|
}
|
|
|
|
self.mouseHasLeft && hideInterface();
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 18:05:29 +00:00
|
|
|
function toggleFind() {
|
2011-05-17 07:43:20 +00:00
|
|
|
var show = self.$find.is(':hidden');
|
|
|
|
!show && self.$findInput.blurInput();
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$find.toggle();
|
2011-05-17 07:43:20 +00:00
|
|
|
show && self.$findInput.focusInput(false);
|
2011-05-16 18:05:29 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:01:40 +00:00
|
|
|
function toggleFullscreen(from) {
|
2011-05-17 17:04:33 +00:00
|
|
|
var parentOffset, playOnFullscreen;
|
2011-05-15 07:26:00 +00:00
|
|
|
self.options.fullscreen = !self.options.fullscreen;
|
|
|
|
if (!self.options.paused) {
|
2011-05-15 16:18:58 +00:00
|
|
|
// video won't keep playing accross detach/append
|
2011-05-15 07:26:00 +00:00
|
|
|
self.video.pause();
|
2011-05-17 17:04:33 +00:00
|
|
|
playOnFullscreen = true;
|
2011-05-15 07:26:00 +00:00
|
|
|
}
|
|
|
|
if (self.options.fullscreen) {
|
|
|
|
self.$parent = that.parent();
|
2011-05-15 07:52:37 +00:00
|
|
|
parentOffset = self.$parent.offset();
|
|
|
|
self.absoluteOffset = that.offset();
|
|
|
|
self.relativeOffset = {
|
|
|
|
left: self.absoluteOffset.left - parentOffset.left,
|
|
|
|
top: self.absoluteOffset.top - parentOffset.top
|
|
|
|
};
|
2011-05-15 07:26:00 +00:00
|
|
|
that.detach()
|
|
|
|
.css({
|
2011-05-15 07:52:37 +00:00
|
|
|
left: self.absoluteOffset.left + 'px',
|
|
|
|
top: self.absoluteOffset.top + 'px',
|
2011-05-15 07:26:00 +00:00
|
|
|
zIndex: 1000
|
|
|
|
})
|
|
|
|
.appendTo(Ox.UI.$body);
|
|
|
|
setSizes(function() {
|
2011-05-17 17:04:33 +00:00
|
|
|
playOnFullscreen && self.video.play();
|
2011-05-15 16:18:58 +00:00
|
|
|
that.bind({
|
|
|
|
mousemove: function() {
|
2011-05-17 20:20:43 +00:00
|
|
|
showInterface();
|
|
|
|
//if (!self.mouseIsInControls) {
|
2011-05-15 16:18:58 +00:00
|
|
|
hideInterface();
|
2011-05-17 20:20:43 +00:00
|
|
|
//}
|
2011-05-15 16:18:58 +00:00
|
|
|
}
|
|
|
|
});
|
2011-05-16 18:05:29 +00:00
|
|
|
that.find('.OxControls').bind({
|
2011-05-15 16:18:58 +00:00
|
|
|
mouseenter: function() {
|
|
|
|
self.mouseIsInControls = true;
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
self.mouseIsInControls = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
showInterface();
|
|
|
|
hideInterface();
|
2011-05-15 07:26:00 +00:00
|
|
|
});
|
|
|
|
} else {
|
2011-05-15 16:18:58 +00:00
|
|
|
// flag makes the animation end on absolute position
|
2011-05-15 07:52:37 +00:00
|
|
|
self.exitFullscreen = true;
|
2011-05-15 16:18:58 +00:00
|
|
|
that.unbind('mousemove');
|
2011-05-16 18:05:29 +00:00
|
|
|
that.find('.OxControls')
|
2011-05-15 16:18:58 +00:00
|
|
|
.trigger('mouseleave')
|
|
|
|
.unbind('mouseenter')
|
|
|
|
.unbind('mouseleave');
|
2011-05-17 20:20:43 +00:00
|
|
|
clearTimeout(self.interfaceTimeout);
|
2011-05-15 07:26:00 +00:00
|
|
|
setSizes(function() {
|
2011-05-15 16:18:58 +00:00
|
|
|
self.exitFullscreen = false;
|
2011-05-15 07:26:00 +00:00
|
|
|
that.detach()
|
|
|
|
.css({
|
2011-05-15 07:52:37 +00:00
|
|
|
left: self.relativeOffset.left + 'px',
|
2011-05-16 18:05:29 +00:00
|
|
|
top: self.relativeOffset.top + 'px',
|
|
|
|
zIndex: 1
|
2011-05-15 07:26:00 +00:00
|
|
|
})
|
|
|
|
.appendTo(self.$parent);
|
2011-05-17 17:04:33 +00:00
|
|
|
playOnFullscreen && self.video.play();
|
2011-05-15 16:18:58 +00:00
|
|
|
self.options.enableKeyboard && that.gainFocus();
|
|
|
|
//showInterface();
|
2011-05-15 07:26:00 +00:00
|
|
|
});
|
|
|
|
}
|
2011-05-17 18:01:40 +00:00
|
|
|
if (self.$fullscreenButton && from != 'button') {
|
2011-05-15 16:18:58 +00:00
|
|
|
self.$fullscreenButton.toggleTitle();
|
|
|
|
}
|
2011-05-15 07:26:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:01:40 +00:00
|
|
|
function toggleMuted(from) {
|
2011-05-13 15:44:50 +00:00
|
|
|
self.options.muted = !self.options.muted;
|
|
|
|
self.video.muted = self.options.muted;
|
2011-05-17 07:05:21 +00:00
|
|
|
if (!self.options.muted && !self.options.volume) {
|
|
|
|
self.options.volume = 1;
|
|
|
|
self.video.volume = 1;
|
|
|
|
}
|
2011-05-17 18:01:40 +00:00
|
|
|
if (self.$muteButton && from != 'button') {
|
2011-05-15 16:18:58 +00:00
|
|
|
self.$muteButton.toggleTitle();
|
|
|
|
}
|
2011-05-16 18:05:29 +00:00
|
|
|
self.$volumeButton && self.$volumeButton.attr({
|
|
|
|
src: getVolumeImageURL()
|
|
|
|
});
|
|
|
|
self.$volumeInput && self.$volumeInput.options({
|
|
|
|
value: self.options.muted ? 0 : self.options.volume
|
|
|
|
});
|
2011-05-17 07:05:21 +00:00
|
|
|
self.$volumeValue && self.$volumeValue.html(
|
|
|
|
self.options.muted ? 0 : Math.round(self.options.volume * 100)
|
|
|
|
);
|
2011-05-12 10:39:48 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:01:40 +00:00
|
|
|
function togglePaused(from) {
|
2011-05-13 15:44:50 +00:00
|
|
|
self.options.paused = !self.options.paused;
|
2011-05-16 11:29:26 +00:00
|
|
|
self.$timeline && self.$timeline.options({
|
|
|
|
paused: self.options.paused
|
2011-05-12 10:39:48 +00:00
|
|
|
});
|
2011-05-13 15:44:50 +00:00
|
|
|
if (self.options.paused) {
|
|
|
|
self.video.pause();
|
|
|
|
clearInterval(self.playInterval);
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.showIcon) {
|
|
|
|
togglePlayIcon();
|
|
|
|
self.options.showIcon && self.$playIcon.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, 250);
|
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
} else {
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.playInToOut && self.options.position > self.options.out - self.secondsPerFrame) {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(self.options['in']);
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
self.video.play();
|
|
|
|
self.playInterval = setInterval(playing, self.millisecondsPerFrame);
|
2011-05-14 19:32:49 +00:00
|
|
|
if (self.options.showIcon) {
|
|
|
|
self.options.showIcon && self.$playIcon.animate({
|
|
|
|
opacity: 0
|
2011-05-15 07:26:00 +00:00
|
|
|
}, 250, togglePlayIcon);
|
2011-05-14 19:32:49 +00:00
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
2011-05-17 18:01:40 +00:00
|
|
|
if (self.$playButton && from != 'button') {
|
2011-05-15 08:35:00 +00:00
|
|
|
self.$playButton.toggleTitle();
|
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function togglePlayIcon() {
|
2011-05-14 19:32:49 +00:00
|
|
|
self.$playIcon.attr({
|
|
|
|
src: Ox.UI.getImagePath(
|
|
|
|
'symbol' + (self.options.paused ? 'Play' : 'Pause'
|
|
|
|
)+ '.svg').replace('/classic/', '/modern/')
|
|
|
|
});
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:01:40 +00:00
|
|
|
function toggleScale(from) {
|
2011-05-13 15:44:50 +00:00
|
|
|
self.options.scaleToFill = !self.options.scaleToFill;
|
2011-05-15 07:26:00 +00:00
|
|
|
self.$video.animate(getCSS('video'), 250);
|
2011-05-15 07:52:37 +00:00
|
|
|
self.$poster && self.$poster.animate(getCSS('poster'), 250);
|
2011-05-17 18:01:40 +00:00
|
|
|
if (self.$scaleButton && from != 'button') {
|
2011-05-15 16:18:58 +00:00
|
|
|
self.$scaleButton.toggleTitle();
|
|
|
|
}
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleSize() {
|
|
|
|
self.options.sizeIsLarge = !self.options.sizeIsLarge;
|
|
|
|
that.triggerEvent('size', {
|
|
|
|
size: self.options.sizeIsLarge ? 'large' : 'small'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-05-17 07:43:20 +00:00
|
|
|
function toggleVolume() {
|
|
|
|
self.$volume.toggle();
|
|
|
|
}
|
|
|
|
|
2011-05-14 19:32:49 +00:00
|
|
|
self.setOption = function(key, value) {
|
2011-05-15 07:26:00 +00:00
|
|
|
if (key == 'fullscreen') {
|
2011-05-17 18:01:40 +00:00
|
|
|
toggleFullscreen();
|
2011-05-15 07:26:00 +00:00
|
|
|
} else if (key == 'height' || key == 'width') {
|
2011-05-14 19:32:49 +00:00
|
|
|
setSizes();
|
2011-05-13 15:44:50 +00:00
|
|
|
} else if (key == 'muted') {
|
2011-05-17 18:01:40 +00:00
|
|
|
toggleMuted();
|
2011-05-13 15:44:50 +00:00
|
|
|
} else if (key == 'paused') {
|
2011-05-17 18:01:40 +00:00
|
|
|
togglePaused();
|
2011-05-13 15:44:50 +00:00
|
|
|
} else if (key == 'position') {
|
2011-05-17 18:01:40 +00:00
|
|
|
setPosition(value);
|
2011-05-14 19:32:49 +00:00
|
|
|
} else if (key == 'scaleToFill') {
|
2011-05-17 18:01:40 +00:00
|
|
|
toggleScale();
|
2011-05-13 15:44:50 +00:00
|
|
|
}
|
2011-05-14 19:32:49 +00:00
|
|
|
};
|
2011-05-12 10:39:48 +00:00
|
|
|
|
2011-05-13 15:44:50 +00:00
|
|
|
that.playInToOut = function() {
|
2011-05-14 19:32:49 +00:00
|
|
|
playInToOut();
|
2011-05-13 15:44:50 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2011-05-12 10:39:48 +00:00
|
|
|
return that;
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
};
|