shelfy/templates/media_detail.pages.tmpl

75 lines
2.4 KiB
Cheetah
Raw Normal View History

2025-06-21 18:01:24 +00:00
<section class="section">
<div class="container">
<div class="box">
2025-06-21 18:07:31 +00:00
<!-- Détail avant lecture -->
2025-06-21 18:05:03 +00:00
<div id="detail-block">
<div class="columns is-vcentered">
<div class="column is-one-third">
<figure class="image is-3by4">
<img src="{{.item.ThumbURL}}" alt="{{.item.Title}}" />
</figure>
</div>
<div class="column">
<h1 class="title">{{.item.Title}}</h1>
2025-06-21 18:07:31 +00:00
{{with .item.Summary}}<p class="content">{{.}}</p>{{end}}
{{with .item.DurationFmt}}<p class="subtitle is-6">Durée : {{.}}</p>{{end}}
2025-06-21 18:05:03 +00:00
<button id="play-btn" class="button is-primary">
<span class="icon"><i class="fas fa-play"></i></span>
<span>Play</span>
</button>
</div>
2025-06-21 18:01:24 +00:00
</div>
2025-06-21 18:05:03 +00:00
</div>
2025-06-21 18:07:31 +00:00
<!-- Player après clic -->
2025-06-21 18:05:03 +00:00
<div id="player-block" style="display:none;">
<div class="box">
2025-06-21 18:07:31 +00:00
<video id="video-player" controls autoplay style="width:100%; height:auto;"></video>
2025-06-21 18:05:03 +00:00
<button id="close-btn" class="button is-light mt-4">
<span class="icon"><i class="fas fa-times"></i></span>
<span>Fermer</span>
2025-06-21 18:01:24 +00:00
</button>
</div>
</div>
2025-06-21 18:07:31 +00:00
2025-06-21 18:01:24 +00:00
</div>
</div>
</section>
2025-06-21 18:05:03 +00:00
2025-06-21 18:07:31 +00:00
<script src="https://unpkg.com/hls.js@1.4.0"></script>
2025-06-21 18:05:03 +00:00
<script>
document.addEventListener('DOMContentLoaded', function() {
var playBtn = document.getElementById('play-btn');
var closeBtn = document.getElementById('close-btn');
var detailBlock = document.getElementById('detail-block');
var playerBlock = document.getElementById('player-block');
var video = document.getElementById('video-player');
playBtn.addEventListener('click', function() {
detailBlock.style.display = 'none';
playerBlock.style.display = 'block';
2025-06-21 18:07:31 +00:00
var url = "{{.item.HLSURL}}";
2025-06-21 18:05:03 +00:00
if (Hls.isSupported()) {
var hls = new Hls();
2025-06-21 18:07:31 +00:00
hls.loadSource(url);
2025-06-21 18:05:03 +00:00
hls.attachMedia(video);
2025-06-21 18:07:31 +00:00
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
2025-06-21 18:05:03 +00:00
} else {
2025-06-21 18:07:31 +00:00
console.error('HLS non supporté');
2025-06-21 18:05:03 +00:00
}
2025-06-21 18:07:31 +00:00
playBtn.style.display = 'none';
2025-06-21 18:05:03 +00:00
});
closeBtn.addEventListener('click', function() {
2025-06-21 18:07:31 +00:00
if (!video.paused) video.pause();
video.src = '';
2025-06-21 18:05:03 +00:00
playerBlock.style.display = 'none';
detailBlock.style.display = 'block';
2025-06-21 18:07:31 +00:00
playBtn.style.display = 'inline-flex';
2025-06-21 18:05:03 +00:00
});
});
</script>
2025-06-21 18:07:31 +00:00