Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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   * Fixture for testing the functionality of core_media_player.
  19   *
  20   * @package     core
  21   * @subpackage  fixtures
  22   * @category    test
  23   * @copyright   2012 The Open University
  24   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * Media player stub for testing purposes.
  31   *
  32   * @copyright   2012 The Open University
  33   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class media_test_plugin extends core_media_player {
  36      /** @var array Array of supported extensions */
  37      public $ext;
  38      /** @var int Player rank */
  39      public $rank;
  40      /** @var int Arbitrary number */
  41      public $num;
  42  
  43      /**
  44       * Constructor is used for tuning the fixture.
  45       *
  46       * @param int $num Number (used in output)
  47       * @param int $rank Player rank
  48       * @param array $ext Array of supported extensions
  49       */
  50      public function __construct($num = 1, $rank = 13, $ext = array('mp3', 'flv', 'f4v', 'mp4')) {
  51          $this->ext = $ext;
  52          $this->rank = $rank;
  53          $this->num = $num;
  54      }
  55  
  56      /**
  57       * Generates code required to embed the player.
  58       *
  59       * @param array $urls URLs of media files
  60       * @param string $name Display name; '' to use default
  61       * @param int $width Optional width; 0 to use default
  62       * @param int $height Optional height; 0 to use default
  63       * @param array $options Options array
  64       * @return string HTML code for embed
  65       */
  66      public function embed($urls, $name, $width, $height, $options) {
  67          self::pick_video_size($width, $height);
  68          $contents = "\ntestsource=". join("\ntestsource=", $urls) .
  69              "\ntestname=$name\ntestwidth=$width\ntestheight=$height\n<!--FALLBACK-->\n";
  70          return html_writer::span($contents, 'mediaplugin mediaplugin_test');
  71      }
  72  
  73      /**
  74       * Gets the list of file extensions supported by this media player.
  75       *
  76       * @return array Array of strings (extension not including dot e.g. '.mp3')
  77       */
  78      public function get_supported_extensions() {
  79          return $this->ext;
  80      }
  81  
  82      /**
  83       * Gets the ranking of this player.
  84       *
  85       * @return int Rank
  86       */
  87      public function get_rank() {
  88          return 10;
  89      }
  90  }