/**
  * Test for core_media::get_extension.
  */
 public function test_get_extension()
 {
     $this->assertSame('mp4', core_media::get_extension(new moodle_url('/pluginfile.php/312/mod_page/content/7/frog.mp4')));
     $this->assertSame('', core_media::get_extension(new moodle_url('/pluginfile.php/312/mod_page/content/7/frog')));
     $this->assertSame('mp4', core_media::get_extension(new moodle_url('/pluginfile.php?file=/312/mod_page/content/7/frog.mp4')));
     $this->assertSame('', core_media::get_extension(new moodle_url('/pluginfile.php?file=/312/mod_page/content/7/frog')));
 }
Exemple #2
0
 public function list_supported_urls(array $urls, array $options = array())
 {
     $extensions = $this->get_supported_extensions();
     $result = array();
     foreach ($urls as $url) {
         $ext = core_media::get_extension($url);
         if (in_array($ext, $extensions)) {
             if ($ext === 'ogg' || $ext === 'oga') {
                 // Formats .ogg and .oga are not supported in IE, Edge, or Safari.
                 if (core_useragent::is_ie() || core_useragent::is_edge() || core_useragent::is_safari()) {
                     continue;
                 }
             } else {
                 // Formats .aac, .mp3, and .m4a are not supported in Opera.
                 if (core_useragent::is_opera()) {
                     continue;
                 }
                 // Formats .mp3 and .m4a were not reliably supported in Firefox before 27.
                 // https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
                 // has the details. .aac is still not supported.
                 if (core_useragent::is_firefox() && ($ext === 'aac' || !core_useragent::check_firefox_version(27))) {
                     continue;
                 }
             }
             // Old Android versions (pre 2.3.3) 'support' audio tag but no codecs.
             if (core_useragent::is_webkit_android() && !core_useragent::is_webkit_android('533.1')) {
                 continue;
             }
             $result[] = $url;
         }
     }
     return $result;
 }
Exemple #3
0
 public function list_supported_urls(array $urls, array $options = array())
 {
     $extensions = $this->get_supported_extensions();
     $result = array();
     foreach ($urls as $url) {
         $ext = core_media::get_extension($url);
         if (in_array($ext, $extensions)) {
             if ($ext === 'ogg' || $ext === 'oga') {
                 // Formats .ogg and .oga are not supported in IE or Safari.
                 if (core_useragent::is_ie() || core_useragent::is_safari()) {
                     continue;
                 }
             } else {
                 // Formats .aac, .mp3, and .m4a are not supported in Firefox or Opera.
                 if (core_useragent::is_firefox() || core_useragent::is_opera()) {
                     continue;
                 }
             }
             // Old Android versions (pre 2.3.3) 'support' audio tag but no codecs.
             if (core_useragent::is_webkit_android() && !core_useragent::is_webkit_android('533.1')) {
                 continue;
             }
             $result[] = $url;
         }
     }
     return $result;
 }
 /**
  * Given a list of URLs, returns a reduced array containing only those URLs
  * which are supported by this player. (Empty if none.)
  * @param array $urls Array of moodle_url
  * @param array $options Options (same as will be passed to embed)
  * @return array Array of supported moodle_url
  */
 public function list_supported_urls(array $urls, array $options = array())
 {
     $extensions = $this->get_supported_extensions();
     $result = array();
     foreach ($urls as $url) {
         // If RTMP support is disabled, skip the URL.
         if (!get_config('filter_jwplayer', 'supportrtmp') && $url->get_scheme() === 'rtmp') {
             continue;
         }
         // If RTMP support is enabled, URL is supported.
         if (get_config('filter_jwplayer', 'supportrtmp') && $url->get_scheme() === 'rtmp') {
             $result[] = $url;
             continue;
         }
         if (in_array(core_media::get_extension($url), $extensions)) {
             // URL is matching one of enabled extensions.
             $result[] = $url;
         }
     }
     return $result;
 }
 public function list_supported_urls(array $urls, array $options = array())
 {
     $extensions = $this->get_supported_extensions();
     $result = array();
     foreach ($urls as $url) {
         $ext = core_media::get_extension($url);
         if (in_array($ext, $extensions)) {
             if ($ext === 'ogg' || $ext === 'oga') {
                 // Formats .ogg and .oga are not supported in IE or Safari.
                 if (check_browser_version('MSIE') || check_browser_version('Safari')) {
                     continue;
                 }
             } else {
                 // Formats .aac, .mp3, and .m4a are not supported in Firefox or Opera.
                 if (check_browser_version('Firefox') || check_browser_version('Opera')) {
                     continue;
                 }
             }
             // Old Android versions (pre 2.3.3) 'support' audio tag but no codecs.
             if (check_browser_version('WebKit Android') && !check_browser_version('WebKit Android', '533.1')) {
                 continue;
             }
             $result[] = $url;
         }
     }
     return $result;
 }
 /**
  * Given a list of URLs, returns a reduced array containing only those URLs
  * which are supported by this player.
  *
  * This media player only supports local urls.
  *
  * @param array $urls Array of moodle_url
  * @param array $options Options (same as will be passed to embed)
  * @return array Array of supported moodle_url
  */
 public function list_supported_urls(array $urls, array $options = array())
 {
     $extensions = $this->get_supported_extensions();
     $result = array();
     foreach ($urls as $url) {
         try {
             $url->out_as_local_url();
         } catch (coding_exception $e) {
             continue;
         }
         if (in_array(core_media::get_extension($url), $extensions)) {
             $result[] = $url;
         }
     }
     return $result;
 }