pandora_userscripts/playedit.js

71 lines
2.0 KiB
JavaScript

//open User->Preferences->Advanced->Run Script on Load and paste this script
(function() {
edit('user:example');
// settings and helper functions below
var resolution = [window.innerWidth, window.innerHeight],
outerHeight = 24 + 16 + 16 + 96, // menu bars + timeline bottom
sidebarSize = resolution[0] - ((resolution[1] - outerHeight) * 4/3),
tvUI = {
clipSize: sidebarSize,
annotationsRange: 'position',
editView: 'annotations',
section: 'edits',
showAnnotations: true,
showTimeline: true,
showSidebar: false,
videoLoop: true,
videoScale: 'fit'
};
function edit(edit, position) {
pandora.UI.set({
page: ''
});
position = position || 0;
pandora.UI.set(Ox.extend({
edit: edit
}, tvUI, 'edits.' + edit + '.position', position));
waitForPlayer(function(player) {
//fixGUI();
player.options({
paused: false,
position: position
});
});
}
function waitForPlayer(callback) {
var $player, player;
if (pandora.$ui.editPanel) {
$player = $('.OxVideoPlayer').not('.OxBar');
var readyState = 0;
if($player.find('video').length) {
$player.find('video').each(function() {
readyState = Math.max(readyState, this.readyState);
});
}
if(readyState && $player.data('oxid') && Ox.$elements[$player.data('oxid')]) {
player = Ox.$elements[$player.data('oxid')];
}
}
if (player) {
setTimeout(function() {
callback(player, $player);
}, 250);
} else {
setTimeout(function() {
waitForPlayer(callback);
}, 250);
}
}
function fixGUI() {
// hide menu
pandora.$ui.appPanel.resizeElement(0, 0);
}
})();