Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Main class for plugin 'media_vimeo'
  19   *
  20   * @package   media_vimeo
  21   * @copyright 2016 Marina Glancy
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Player that embeds Vimeo links.
  29   *
  30   * @package   media_vimeo
  31   * @copyright 2016 Marina Glancy
  32   * @author    2011 The Open University
  33   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class media_vimeo_plugin extends core_media_player_external {
  36      protected function embed_external(moodle_url $url, $name, $width, $height, $options) {
  37          $videoid = $this->matches[1];
  38          $info = s($name);
  39  
  40          // Note: resizing via url is not supported, user can click the fullscreen
  41          // button instead. iframe embedding is not xhtml strict but it is the only
  42          // option that seems to work on most devices.
  43          self::pick_video_size($width, $height);
  44  
  45          $output = <<<OET
  46  <span class="mediaplugin mediaplugin_vimeo">
  47  <iframe title="$info" src="https://player.vimeo.com/video/$videoid"
  48    width="$width" height="$height" frameborder="0"
  49    webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  50  </span>
  51  OET;
  52  
  53          return $output;
  54      }
  55  
  56      /**
  57       * Returns regular expression to match vimeo URLs.
  58       * @return string
  59       */
  60      protected function get_regex() {
  61          // Initial part of link.
  62          $start = '~^https?://vimeo\.com/';
  63          // Middle bit: either watch?v= or v/.
  64          $middle = '([0-9]+)';
  65          return $start . $middle . core_media_player_external::END_LINK_REGEX_PART;
  66      }
  67  
  68      public function get_embeddable_markers() {
  69          return array('vimeo.com/');
  70      }
  71  
  72      /**
  73       * Default rank
  74       * @return int
  75       */
  76      public function get_rank() {
  77          return 1010;
  78      }
  79  }