Browse Source

Use mediaelement to show videos instead of unmaintained jsplayer (bis)

BT#14273
jmontoyaa 6 years ago
parent
commit
a083dce527
1 changed files with 11 additions and 67 deletions
  1. 11 67
      main/inc/lib/document.lib.php

+ 11 - 67
main/inc/lib/document.lib.php

@@ -104,6 +104,7 @@ class DocumentManager
             'etx' => 'text/x-setext',
             'exe' => 'application/octet-stream',
             'ez' => 'application/andrew-inset',
+            'flv' => 'video/flv',
             'gif' => 'image/gif',
             'gtar' => 'application/x-gtar',
             'gz' => 'application/x-gzip',
@@ -375,6 +376,7 @@ class DocumentManager
                     header('Content-type: application/octet-stream');
                     break;
             }
+
             header('Content-type: '.$contentType);
             header('Content-Length: '.$len);
             $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
@@ -3078,8 +3080,6 @@ class DocumentManager
      */
     public static function generateAudioJavascript($params = [])
     {
-        $path = api_get_path(WEB_LIBRARY_PATH).'javascript/';
-
         $js = '
             $(\'video:not(.skip), audio.audio_preview\').mediaelementplayer({
                 features: [\'playpause\'],
@@ -3089,26 +3089,6 @@ class DocumentManager
                 }
             });';
 
-        $a = '
-            $("#jquery_jplayer_'.$params['count'].'").jPlayer({
-                ready: function() {
-                    $(this).jPlayer("setMedia", {
-                        '.$params['extension'].' : "'.$params['url'].'"
-                    });
-                },
-                play: function() { // To avoid both jPlayers playing together.
-                    $(this).jPlayer("pauseOthers");
-                },
-                //errorAlerts: true,
-                //warningAlerts: true,
-                swfPath: "'.$path.'jquery-jplayer/jplayer/",
-                //supplied: "m4a, oga, mp3, ogg, wav",
-                supplied: "'.$params['extension'].'",
-                wmode: "window",
-                solution: "flash, html",  // Do not change this setting
-                cssSelectorAncestor: "#jp_container_'.$params['count'].'",
-            });'."\n\n";
-
         return $js;
     }
 
@@ -3130,55 +3110,19 @@ class DocumentManager
     }
 
     /**
-     * @param array $document_data
+     * @param string $file
+     * @param string $extension
      *
      * @return string
      */
-    public static function generate_video_preview($document_data = [])
+    public static function generateVideoPreview($file, $extension)
     {
-        $html = '
-        <div id="jp_container_1" class="jp-video center-block" role="application" aria-label="media player">
-            <div class="jp-type-single">
-                <div id="jquery_jplayer_1" class="jp-jplayer"></div>
-                <div class="jp-gui">
-                    <div class="jp-video-play">
-                    </div>
-                    <div class="jp-interface">
-                        <div class="jp-progress">
-                            <div class="jp-seek-bar">
-                                <div class="jp-play-bar"></div>
-                            </div>
-                        </div>
-                        <div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
-                        <div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
-                        <div class="jp-controls-holder">
-                          <div class="jp-controls">
-                            <button class="jp-play" role="button" tabindex="0">play</button>
-                            <button class="jp-stop" role="button" tabindex="0">stop</button>
-                          </div>
-                          <div class="jp-volume-controls">
-                            <button class="jp-mute" role="button" tabindex="0">mute</button>
-                            <button class="jp-volume-max" role="button" tabindex="0">max volume</button>
-                            <div class="jp-volume-bar">
-                                <div class="jp-volume-bar-value"></div>
-                            </div>
-                          </div>
-                          <div class="jp-toggles">
-                            <button class="jp-repeat" role="button" tabindex="0">repeat</button>
-                            <button class="jp-full-screen" role="button" tabindex="0">full screen</button>
-                          </div>
-                        </div>
-                        <div class="jp-details">
-                          <div class="jp-title" aria-label="title">&nbsp;</div>
-                        </div>
-                    </div>
-                </div>
-                <div class="jp-no-solution">
-                    <span>'.get_lang('UpdateRequire').'</span>
-                    '.get_lang("ToPlayTheMediaYouWillNeedToUpdateYourBrowserToARecentVersionYouCanAlsoDownloadTheFile").'
-                </div>
-            </div>
-        </div>';
+        $type = '';
+        /*if ($extension != 'flv') {
+
+        }*/
+        //$type = "video/$extension";
+        $html = '<video id="myvideo"  src="'.$file.'" controls '.$type.'">';
 
         return $html;
     }