play edit on home page

This commit is contained in:
j 2023-08-04 19:03:44 +02:00
parent 5eeafec9d2
commit 435d22a656

View file

@ -26,7 +26,8 @@ pandora.ui.home = function() {
width: '560px', width: '560px',
margin: '0 auto 0 auto' margin: '0 auto 0 auto'
}) })
.appendTo(that), .appendTo(that);
/*
$reflectionImage = $('<img>') $reflectionImage = $('<img>')
.attr({src: '/static/png/logo.png'}) .attr({src: '/static/png/logo.png'})
@ -58,8 +59,9 @@ pandora.ui.home = function() {
margin: '0 auto 0 auto', margin: '0 auto 0 auto',
}) })
.appendTo($box), .appendTo($box),
*/
$logo = Ox.Element({ var $logo = Ox.Element({
element: '<img>', element: '<img>',
tooltip: function() { tooltip: function() {
return Ox._('Enter {0}', [pandora.site.site.name]); return Ox._('Enter {0}', [pandora.site.site.name]);
@ -263,6 +265,68 @@ pandora.ui.home = function() {
} }
$aboutButton.appendTo($footer); $aboutButton.appendTo($footer);
function getVideos(clips, resolution) {
var videos = [];
clips.filter(function(clip) {
return clip.duration;
}).map(function(clip) {
videos = videos.concat(pandora.getClipVideos(clip, resolution));
});
console.log(videos)
return videos;
}
function loadEdit() {
pandora.api.getEdit({
id: "mamafih:homepage",
}, response => {
var edit = response.data
pandora.api.sortClips({
edit: edit.id,
sort: [{
key: 'random',
operator: '+'
}]
}, result => {
console.log('!!', result)
edit.clips.forEach(function(clip) {
clip.sort = result.data.clips.indexOf(clip.id);
});
edit.clips = Ox.sortBy(edit.clips, 'sort');
var player = window.player = Ox.VideoElement({
items: getVideos(Ox.clone(edit.clips), pandora.user.ui.videoResolution),
autoplay: true,
muted: true,
loop: true,
}).css({
position: 'fixed',
top: 0,
bottom: 0,
left: 0,
right: 0,
width: '100%',
height: '100%'
})
player.find('video').css({
width: '100%',
height: '100%',
'object-fit': 'cover',
})
player.prependTo(pandora.$ui.home)
player.bindEvent('loadedmetadata', () => {
console.log('now play')
player.play()
setTimeout(() => {
player.play()
}, 1000)
})
})
})
}
loadEdit()
function showFeatures() { function showFeatures() {
pandora.api.getHomeItems({active: true}, function(result) { pandora.api.getHomeItems({active: true}, function(result) {
var items = result.data.items.filter(pandora.isCompleteHomeItem), var items = result.data.items.filter(pandora.isCompleteHomeItem),