<?php
  
ECHO "<div class='list-menu'>";

ECHO "<center>";

IF (IS_FILE(ROOT.'/files/upload/videos/screen/'.$video['ID'].'.jpg') && CONFIG('VIDEO_SCREEN') == 1){
  
  $vv = "'/files/upload/videos/screen/".$video['ID'].".jpg'";

}ELSE{
  
  $vv = "/files/upload/videos/screen/no_video.jpg'";

}

ECHO "<video poster='".$vv."' style='width: 90%;' src='/files/upload/videos/source/".$video['ID'].'.'.$video['EXT']."' controls></video>";

ECHO "</center>";

IF (STR($video['MESSAGE']) > 0){
  
  ECHO '<div style="padding: 3px;">';
  
  IF (STR($video['MESSAGE']) > 120){
    
    ECHO "<div id='opacity_message' class='opacity_message'></div>";
    
    ECHO "<div id='video_s_h' style='margin-top: 5px;'>";
    
    ECHO TEXT(CROP_TEXT($video['MESSAGE'], 0, 120), 1, 0, 0, 0);
    
    ECHO "</div>";
    
    ECHO "<div id='video_s_h2' style='display: none; margin-top: 5px;'>";
    
    ECHO TEXT($video['MESSAGE'], 1, 0, 0, 0);
    
    ECHO "</div>";
    
    ?><a onclick="show_or_hide('video_s_h', 'video_s_h2', 'chevron', 'opacity_message')" load="none"><?
    
    ECHO "<div id='chevron' class='chevron'><i class='fa fa-chevron-down fa-fw'></i></div>";
    
    ECHO "</a>";
  
  }ELSE{
    
    ECHO TEXT($video['MESSAGE'], 1, 0, 0, 0);
  
  }
  
  ECHO "</div>";
  
}

ECHO "</div>";
  
?>
  
<script>
$(document).ready(function(){
    var controls = {
        video: $("#myvideo"),
        playpause: $("#playpause")                 
    };
                
    var video = controls.video[0];
               
    controls.playpause.click(function(){
        if (video.paused) {
            video.play();
            $(this).text("Pause");    
        } else {
            video.pause();
            $(this).text("Play");
        }
                
        $(this).toggleClass("paused"); 
    });
});

var controls = {
    ...  
    togglePlayback: function() {
        (video.paused) ? video.play() : video.pause();
    }
    ...
};
                
controls.playpause.click(function(){
    controls.togglePlayback();
});

video.addEventListener("ended", function() {
    video.pause();
    controls.playpause.text("Play");
    controls.playpause.toggleClass("paused");
});

video.addEventListener("play", function() {
    controls.playpause.text("Pause");
    controls.playpause.toggleClass("paused");
});
                
video.addEventListener("pause", function() {
    controls.playpause.text("Play");
    controls.playpause.toggleClass("paused");
});

controls.video.click(function() {
    controls.togglePlayback();
});
</script>