include more info on film page
This commit is contained in:
parent
844af58b1d
commit
1516b7349a
3 changed files with 78 additions and 71 deletions
38
app/static/js/film.js
Normal file
38
app/static/js/film.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||
var video = document.createElement('video')
|
||||
video.classList.add('player')
|
||||
video.src = 'https://pad.ma/' + film.id + '/480p.webm'
|
||||
video.controls = true
|
||||
document.querySelector('main').appendChild(video)
|
||||
video.style.display = 'none'
|
||||
function enterFullscreen(event) {
|
||||
video.requestFullscreen().catch(err => {
|
||||
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
||||
});
|
||||
video.removeEventListener('play', enterFullscreen);
|
||||
setTimeout(() => {
|
||||
video.style.display = 'block'
|
||||
}, 150)
|
||||
}
|
||||
video.addEventListener('play', enterFullscreen);
|
||||
video.addEventListener('fullscreenchange', event => {
|
||||
if (!document.fullscreen) {
|
||||
video.remove()
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
}
|
||||
});
|
||||
video.addEventListener('pause', event => {
|
||||
})
|
||||
video.addEventListener('ended', event => {
|
||||
video.remove()
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
});
|
||||
video.play()
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
})
|
|
@ -2,21 +2,20 @@
|
|||
{% block main %}
|
||||
|
||||
<div class="film">
|
||||
<div class="info">
|
||||
<h1>{{ film.data.title | safe }}</h1>
|
||||
{% comment %}
|
||||
<h2>{{ film.data.director|join:", "|safe }}</h2>
|
||||
{% endcomment %}
|
||||
<p>{{ film.data.summary|safe }}</p>
|
||||
<div class="details">
|
||||
Runtime: {{ film.duration }},
|
||||
Year: {{ film.data.date}},
|
||||
Artist Bio: {{ film.data.bio|safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<video src="{{ settings.TIMELINE_PREFIX }}{{ film.padma_id }}/loop.mp4" autoplay loop muted></video>
|
||||
<div class="play">
|
||||
<div class="info">
|
||||
<h1>{{ film.data.title | safe }}</h1>
|
||||
{% comment %}
|
||||
<h2>{{ film.data.director|join:", "|safe }}</h2>
|
||||
{% endcomment %}
|
||||
<p>{{ film.data.summary|safe }}</p>
|
||||
<div class="details">
|
||||
Runtime: {{ film.duration }},
|
||||
Year: {{ film.data.date}},
|
||||
Artist Bio: {{ film.data.bio|safe }}
|
||||
</div>
|
||||
</div>
|
||||
<video src="{{ settings.TIMELINE_PREFIX }}{{ film.padma_id }}/loop.mp4" autoplay loop muted></video>
|
||||
<div class="play">
|
||||
<div>
|
||||
<a href="" id="play-fullscreen">Play</a>
|
||||
</div>
|
||||
|
@ -30,54 +29,16 @@ Artist Bio: {{ film.data.bio|safe }}
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://pad.ma/{{ film.padma_id }}/info" target="_blank">Open on pad.ma</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block end %}
|
||||
<script>
|
||||
var film = {
|
||||
id: "{{ film.padma_id }}",
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||
var video = document.createElement('video')
|
||||
video.classList.add('player')
|
||||
video.src = 'https://pad.ma/' + film.id + '/480p.webm'
|
||||
video.controls = true
|
||||
document.querySelector('main').appendChild(video)
|
||||
video.style.display = 'none'
|
||||
function enterFullscreen(event) {
|
||||
video.requestFullscreen().catch(err => {
|
||||
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
||||
});
|
||||
video.removeEventListener('play', enterFullscreen);
|
||||
setTimeout(() => {
|
||||
video.style.display = 'block'
|
||||
}, 150)
|
||||
}
|
||||
video.addEventListener('play', enterFullscreen);
|
||||
video.addEventListener('fullscreenchange', event => {
|
||||
if (!document.fullscreen) {
|
||||
video.remove()
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
}
|
||||
});
|
||||
video.addEventListener('pause', event => {
|
||||
})
|
||||
video.addEventListener('ended', event => {
|
||||
video.remove()
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
});
|
||||
video.play()
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
})
|
||||
var film = {{ film.json | safe }};
|
||||
</script>
|
||||
|
||||
<script src="{% static 'js/film.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import json
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
|
@ -36,6 +37,13 @@ class Film(models.Model):
|
|||
def duration(self):
|
||||
return ox.format_timecode(self.data['duration'])[:-4]
|
||||
|
||||
|
||||
def json(self):
|
||||
data = {}
|
||||
data['id'] = self.padma_id
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
class Edit(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
|
Loading…
Reference in a new issue