forked from 0x2620/pandora
pass in/out to embeded view
This commit is contained in:
parent
d965eb4624
commit
a6c8f68047
2 changed files with 62 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
||||||
/***
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||||
Pandora embed
|
'use strict';
|
||||||
***/
|
|
||||||
Ox.load('UI', {
|
Ox.load('UI', {
|
||||||
debug: false,
|
debug: false,
|
||||||
hideScreen: false,
|
hideScreen: false,
|
||||||
|
@ -14,16 +14,15 @@ Ox.load('UI', {
|
||||||
site: data.site,
|
site: data.site,
|
||||||
user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user,
|
user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user,
|
||||||
ui: {},
|
ui: {},
|
||||||
clip: function(item, inPoint, outPoint) {
|
clip: function(options) {
|
||||||
//Ox.print('!@#!@#!@#', inPoint, outPoint);
|
|
||||||
var that = Ox.Element();
|
var that = Ox.Element();
|
||||||
pandora.api.get({id: item, keys: []}, function(result) {
|
pandora.api.get({id: options.item, keys: []}, function(result) {
|
||||||
var video = {};
|
var video = {};
|
||||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||||
var part = (i + 1),
|
var part = (i + 1),
|
||||||
prefix = pandora.site.site.videoprefix.replace('PART', part);
|
prefix = pandora.site.site.videoprefix.replace('PART', part);
|
||||||
return prefix + '/' + item + '/'
|
return prefix + '/' + options.item + '/'
|
||||||
+ resolution + 'p' + part + '.' + pandora.user.videoFormat;
|
+ resolution + 'p' + part + '.' + pandora.user.videoFormat;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,25 +36,27 @@ Ox.load('UI', {
|
||||||
enableVolume: true,
|
enableVolume: true,
|
||||||
externalControls: false,
|
externalControls: false,
|
||||||
height: document.height,
|
height: document.height,
|
||||||
'in': inPoint,
|
'in': options['in'],
|
||||||
out: outPoint,
|
out: options.out,
|
||||||
paused: true,
|
paused: options.paused,
|
||||||
position: inPoint,
|
position: options['in'],
|
||||||
poster: '/' + item + '/' + '128p' + inPoint +'.jpg',
|
poster: '/' + options.item + '/' + '128p' + options['in'] +'.jpg',
|
||||||
showMarkers: false,
|
showMarkers: false,
|
||||||
showMilliseconds: 0,
|
showMilliseconds: 0,
|
||||||
timeline: '/' + item + '/' + 'timeline16p.png',
|
timeline: '/' + options.item + '/' + 'timeline16p.png',
|
||||||
title: result.data.title,
|
title: result.data.title,
|
||||||
video: video,
|
video: video,
|
||||||
width: document.width,
|
width: document.width
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
position: function(data) {
|
position: function(data) {
|
||||||
if(data.position<inPoint || data.position>outPoint) {
|
if(data.position<options['in']
|
||||||
if(!pandora.player.options('paused'))
|
|| data.position > options.out) {
|
||||||
|
if(!pandora.player.options('paused')) {
|
||||||
pandora.player.togglePaused();
|
pandora.player.togglePaused();
|
||||||
|
}
|
||||||
pandora.player.options({
|
pandora.player.options({
|
||||||
position: inPoint,
|
position: options['in'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,17 +65,39 @@ Ox.load('UI', {
|
||||||
Ox.UI.hideLoadingScreen();
|
Ox.UI.hideLoadingScreen();
|
||||||
});
|
});
|
||||||
return that;
|
return that;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
Ox.extend(pandora.user, {
|
Ox.extend(pandora.user, {
|
||||||
videoFormat: Ox.UI.getVideoFormat(pandora.site.video.formats)
|
videoFormat: Ox.UI.getVideoFormat(pandora.site.video.formats)
|
||||||
});
|
});
|
||||||
var item = document.location.pathname.split('/')[1],
|
|
||||||
inPoint = 10,
|
function parseQuery() {
|
||||||
outPoint = 15;
|
var vars = window.location.search.length
|
||||||
pandora.ui.info = pandora.clip(item, inPoint, outPoint)
|
? window.location.search.substring(1).split('&')
|
||||||
|
: [],
|
||||||
|
query = {
|
||||||
|
item: window.location.pathname.substring(1).split('/')[0]
|
||||||
|
},
|
||||||
|
defaults = {
|
||||||
|
view: 'video',
|
||||||
|
'in': 0,
|
||||||
|
out: 10,
|
||||||
|
paused: true,
|
||||||
|
item: ''
|
||||||
|
};
|
||||||
|
vars.forEach(function(v) {
|
||||||
|
v= v.split('=');
|
||||||
|
query[v[0]] = decodeURIComponent(v[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ox.extend({}, defaults, query);
|
||||||
|
}
|
||||||
|
var options = parseQuery();
|
||||||
|
if (options.view == 'video') {
|
||||||
|
pandora.ui.info = pandora.clip(options)
|
||||||
.css({width: '100%', height: '100%'})
|
.css({width: '100%', height: '100%'})
|
||||||
.appendTo(document.body);
|
.appendTo(document.body);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,9 +31,21 @@ pandora.ui.embedDialog = function(data) {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
close: function(data) {
|
close: function(data) {
|
||||||
}
|
}
|
||||||
}),
|
});
|
||||||
url = document.location.origin + '/' + pandora.user.ui.item + '/embed';
|
|
||||||
|
data.view = 'video';
|
||||||
|
|
||||||
|
function constructUrl(data) {
|
||||||
|
var url = document.location.origin + '/' + pandora.user.ui.item + '/embed?',
|
||||||
|
query = [];
|
||||||
|
Ox.forEach(data, function(value, key) {
|
||||||
|
if(key[0] != '_') {
|
||||||
|
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return url + query.join('&');
|
||||||
|
}
|
||||||
content.html('To embed this video you need unicorns... or try this code:<br>');
|
content.html('To embed this video you need unicorns... or try this code:<br>');
|
||||||
content.append($('<textarea>').css({width:"100%", height:"100%"}).val('<iframe width="'+width+'" height="'+height+'" src="'+url+'" frameborder="0" allowfullscreen></iframe>'));
|
content.append($('<textarea>').css({width:"100%", height:"100%"}).val('<iframe width="'+width+'" height="'+height+'" src="'+constructUrl(data)+'" frameborder="0" allowfullscreen></iframe>'));
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue