Advertisement
phpface

Untitled

Jun 9th, 2022
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  * The player template file
  5.  *
  6.  */
  7. $source = streamtube_core()->get()->post->get_source();
  8.  
  9. if( wp_attachment_is( 'video', $source ) ){
  10.     $source = wp_get_attachment_url( $source );
  11.     $mime_type = get_post_mime_type( $source );
  12.  
  13.     // If source is HLS, you have to set the mime_type to 'application/x-mpegurl' manually.
  14.     ?>
  15.    
  16.     <div class="video-js vjs-16-9 theoplayer-container theoplayer-skin" style="max-width: unset;"></div>
  17.  
  18.     <script>
  19.         var element = document.querySelector('.theoplayer-container');
  20.         var player = new THEOplayer.Player(element, {
  21.         libraryLocation : '/path/to/libraryLocation/'
  22.         });
  23.  
  24.         player.source = {
  25.             sources : [{
  26.                 src : '<?php echo $source; ?>',
  27.                 type : '<?php echo $mime_type; ?>'
  28.             }]
  29.         };
  30.     </script>
  31.     <?php
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement