gonzopi

git clone https://git.tarina.org/gonzopi
Log | Files | Refs | README | LICENSE

player.html (3176B)


      1 $def with (real_filmfolder,filmfolder,film,scene,shot,take,str,randhash,has_audio_track)
      2 $ video=''
      3 $ audio=''
      4 $if shot != None and take != None:
      5     $ video = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/take' + str(take).zfill(3) + '.mp4'
      6     $ video_realpath = '/'+real_filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/take' + str(take).zfill(3) + '.mp4'
      7     $ title = film + ' scene|' + str(scene).zfill(3) + ' shot|' + str(shot).zfill(3) + ' take|' + str(take).zfill(3)
      8     $ audio = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/take' + str(take).zfill(3) + '.wav'
      9 $elif scene != None:
     10     $ video = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/scene.mp4'
     11     $ video_realpath = '/'+real_filmfolder + film + '/scene' + str(scene).zfill(3) + '/scene.mp4'
     12     $ audio = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/scene.wav'
     13     $ title = film + ' scene|' + str(scene).zfill(3)
     14 $elif film != None:
     15     $ video = '/'+filmfolder + film + '/'+film+'.mp4'
     16     $ video_realpath = '/'+real_filmfolder + film + '/'+film+'.mp4'
     17     $ audio = '/'+filmfolder + film + '/'+film+'.wav'
     18     $ title = film
     19 <h3>$title</h3>
     20 $if has_audio_track(video_realpath) == False:
     21     <div class="player-container">
     22     <video id="videoPlayer" controls>
     23         <source src="$video?randhash" type="video/mp4">
     24         Your browser does not support the video element.
     25     </video>
     26     <audio id="audioPlayer">
     27         <source src="$audio?randhash" type="audio/wav">
     28         Your browser does not support the audio element.
     29     </audio>
     30     <div class="controls">
     31     </div>
     32     </div>
     33 
     34     <script>
     35     const video = document.getElementById('videoPlayer');
     36     const audio = document.getElementById('audioPlayer');
     37 
     38     // Sync video and audio playback
     39     video.addEventListener('play', () => {
     40         audio.play();
     41     });
     42 
     43     video.addEventListener('pause', () => {
     44         audio.pause();
     45     });
     46 
     47     // Sync playhead movement
     48     video.addEventListener('seeked', () => {
     49         audio.currentTime = video.currentTime;
     50     });
     51 
     52     // Keep audio in sync during playback
     53     video.addEventListener('timeupdate', () => {
     54         if (Math.abs(video.currentTime - audio.currentTime) > 0.5) {
     55             audio.currentTime = video.currentTime;
     56         }
     57     });
     58 
     59     // Optional: Handle playback rate changes
     60     video.addEventListener('ratechange', () => {
     61         audio.playbackRate = video.playbackRate;
     62     });
     63 
     64     // Control functions
     65     function playBoth() {
     66         video.play();
     67         audio.play();
     68     }
     69 
     70     function pauseBoth() {
     71         video.pause();
     72         audio.pause();
     73     }
     74 
     75     // Ensure audio stays muted if video is muted
     76     video.addEventListener('volumechange', () => {
     77         audio.muted = video.muted;
     78         audio.volume = video.volume;
     79     });
     80     </script>
     81 $else:
     82     <div class="player-container">
     83     <video id="videoPlayer" controls>
     84         <source src="$video?randhash" type="video/mp4">
     85         Your browser does not support the video element.
     86     </video>
     87 
     88 <h3><a href="/c">BACK</a></h3>