/usr/share/vdr/plugins/live/js/live/vlc.js is in vdr-plugin-live 0.2.0+git20130305-6.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | /*
* This is part of the live vdr plugin. See COPYING for license information.
*
* VLC class.
*
* This class adds convenience methods to a embeded vlc media player
* object and allows control of the player and provides an event interface.
*/
/*
Class: VLC
A VLC plugin wrapper.
Arguments:
id - The id of the embedded vlc plugin.
options - optional arguments, helping to tweak this class to your html.
Options:
autoresize - if true, the player will be resized with the browser window.
controlsContainer - the id of the DOM element that contains the controls.
controls - an array describing which controls are provided by the html
page. Current supported types: play, mute, screen,
close. for each type your page wants to provide an
inline object is expected with with the following
properties:
type - one of the types above to map to the class internal
functions for that type.
id - the DOM id of the control.
classes - on: class to add when toggled on.
- off: class to add when toggled off.
Events:
ontoggle - event fired after the toggling of one property took place.
*/
var VLC = new Class({
options: {
autoresize: true,
controlsContainer: "vlcControls",
// select by type the actions should be performed by a
// instanciated object of class VLC. Possible types you find
// below in the 'actions' definition.
controls: [
{ type: 'play',
id: "TogglePlay",
classes: { on: "red", off: "green" }},
{ type: 'mute',
id: "ToggleMute",
classes: { on: "green", off: "red" }},
{ type: 'screen',
id: "FullScreen",
classes: { on: "blue", off: "blue" }},
{ type: 'close',
id: "Close",
classes: { on: "yellow", off: "yellow" }},
],
offset: 5,
playRecording: false
},
initialize: function(id, options){
this.setOptions(options);
this.id = id;
window.addEvent('domready', this.playerSetup.bind(this));
},
playerSetup: function(){
this.vlc = $(this.id);
this.newVlcApi = (this.vlc.VersionInfo != null);
// add here new actions these class might support:
var actions = {
play: { check: this.isPlaying, toggle: this.togglePlay },
mute: { check: this.isMuted, toggle: this.toggleMute },
screen: { check: Class.empty, toggle: this.toggleScreen },
close: { check: Class.empty, toggle: this.close }};
$each(this.options.controls, function(item, idx){
var elem = $(item.id);
if (elem && actions[item.type]) {
item.fns = actions[item.type];
}
}, this);
this.setStates();
var idx = 0;
$each(this.options.controls, function(item){
if (item.fns && item.fns.toggle)
$(item.id).addEvent('click', function (event, item){
var toggle = item.fns.toggle.bind(this);
var check = item.fns.check.bind(this);
toggle();
this.fireEvent('toggle', [item.id, check()]);
}.bindWithEvent(this, item));
}, this);
if (this.options.autoresize) {
window.addEvent('resize', this.playerResize.bind(this));
}
},
enableDeinterlace: function(){
if (this.newVlcApi) {
this.vlc.video.deinterlace.enable("yadif");
}
},
disableDeinterlace: function(){
if (this.newVlcApi) {
this.vlc.video.deinterlace.disable();
}
},
playerResize: function(el){
var winwidth = window.getWidth();
var winheight = window.getHeight();
winheight -= $(this.options.controlsContainer).getSize().size.y;
winheight -= this.options.offset;
this.vlc.setStyle('width', winwidth);
this.vlc.setStyle('height', winheight);
},
isPlaying: function(){
if (this.newVlcApi)
return this.vlc.playlist && this.vlc.playlist.isPlaying;
else
return this.vlc.isplaying();
},
isMuted: function(){
if (this.newVlcApi)
return this.vlc.audio && this.vlc.audio.mute;
else {
var res = this.vlc.get_volume();
return 0 == res;
}
},
togglePlay: function(){
if (this.newVlcApi)
if (!this.options.playRecording)
this.vlc.playlist.togglePause();
else {
if (this.vlc.playlist.isPlaying) {
clearTimeout(this.deint);
this.disableDeinterlace();
this.vlc.playlist.stop();
else {
this.vlc.playlist.play();
this.deint = setTimeout(this.enableDeinterlace, 500);
}
}
else {
if (this.isPlaying())
this.vlc.stop();
else
this.vlc.play();
}
this.setStates();
},
toggleMute: function(){
if (this.newVlcApi)
this.vlc.audio.toggleMute();
else
this.vlc.mute();
this.setStates();
},
toggleScreen: function(){
if (this.newVlcApi)
this.vlc.video.toggleFullscreen();
else
this.vlc.fullscreen();
this.setStates();
},
close: function(){
window.close();
},
setStates: function(){
$each(this.options.controls, function(item, idx){
if (item.fns && (Class.empty != item.fns.check)) {
var fn = item.fns.check.bind(this);
if (fn()) {
$(item.id).removeClass(item.classes.off);
$(item.id).addClass(item.classes.on);
}
else {
$(item.id).removeClass(item.classes.on);
$(item.id).addClass(item.classes.off);
}
}
}, this);
}
});
VLC.implement(new Events, new Options);
|