Commit 2a3527cc authored by Sara Arjona's avatar Sara Arjona
Browse files

MDL-72407 videojs: Remove videojs-flash and videojs-swf libraries

Apart from removing these libraries because the Flash Player was deprecated
in 2017 and officially discontinued on 31 December 2020, the rtmp and useflash
settings have been removed too (they make no sense anymore).
parent 1a9bee69
......@@ -36,7 +36,6 @@ class filter_mediaplugin_testcase extends advanced_testcase {
// We need to enable the media plugins.
\core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5video,html5audio');
set_config('useflash', true, 'media_videojs');
$filterplugin = new filter_mediaplugin(null, array());
......@@ -59,7 +58,6 @@ class filter_mediaplugin_testcase extends advanced_testcase {
'<a href="http://youtu.be/JghQgA2HMX8" class="href=css">test file</a>',
'<a href="http://y2u.be/JghQgA2HMX8" class="href=css">test file</a>',
'<a class="youtube" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
'<a class="_blanktarget" href="http://moodle.org/testfile/test.flv?d=100x100">test flv</a>',
'<a class="hrefcss" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
'<a class="content" href="http://moodle.org/testfile/test.ogg">test ogg</a>',
'<a id="audio" href="http://moodle.org/testfile/test.mp3">test mp3</a>',
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -24,7 +24,6 @@
*/
import Ajax from 'core/ajax';
import Config from 'core/config';
import {eventTypes} from 'core_filters/events';
import LocalStorage from 'core/localstorage';
import Notification from 'core/notification';
......@@ -88,14 +87,10 @@ const notifyVideoJS = e => {
// Add YouTube to the list of modules we require.
modulePromises.push(import('media_videojs/Youtube-lazy'));
}
if (config.techOrder && config.techOrder.indexOf('flash') !== -1) {
// Add Flash to the list of modules we require.
modulePromises.push(import('media_videojs/videojs-flash-lazy'));
}
Promise.all([langStrings, ...modulePromises])
.then(([langJson, videojs]) => {
if (firstLoad) {
videojs.options.flash.swf = `${Config.wwwroot}/media/player/videojs/videojs/video-js.swf`;
videojs.options.playbackRates = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
videojs.options.userActions = {
hotkeys: true,
......
This diff is collapsed.
......@@ -72,10 +72,8 @@ class media_videojs_plugin extends core_media_player_native {
$hasposter = self::get_attribute($text, 'poster') !== null;
}
// Currently Flash in VideoJS does not support responsive layout. If Flash is enabled try to guess
// if HTML5 player will be engaged for the user and then set it to responsive.
$responsive = (get_config('media_videojs', 'useflash') && !$this->youtube) ? null : true;
$flashtech = false;
// Try to guess if HTML5 player will be engaged for the user and then set it to responsive.
$responsive = (!$this->youtube) ? null : true;
// Build list of source tags.
foreach ($urls as $url) {
......@@ -101,10 +99,6 @@ class media_videojs_plugin extends core_media_player_native {
if ($responsive === null) {
$responsive = core_useragent::supports_html5($extension);
}
if (($url->get_scheme() === 'rtmp' || !core_useragent::supports_html5($extension))
&& get_config('media_videojs', 'useflash')) {
$flashtech = true;
}
}
$sources = implode("\n", $sources);
......@@ -123,8 +117,6 @@ class media_videojs_plugin extends core_media_player_native {
$sources = ''; // Do not specify <source> tags - it may confuse browser.
$isaudio = false; // Just in case.
} else if ($flashtech) {
$datasetup[] = '"techOrder": ["flash", "html5"]';
}
// Add a language.
......@@ -258,8 +250,8 @@ class media_videojs_plugin extends core_media_player_native {
get_config('media_videojs', 'audioextensions'))));
$this->extensions = file_get_typegroup('extension', $filetypes);
if ($this->extensions && !get_config('media_videojs', 'useflash')) {
// If Flash is disabled get extensions supported by player that don't rely on flash.
if ($this->extensions) {
// Get extensions supported by player.
$supportedextensions = array_merge(file_get_typegroup('extension', 'html_video'),
file_get_typegroup('extension', 'html_audio'), file_get_typegroup('extension', 'media_source'));
$this->extensions = array_intersect($this->extensions, $supportedextensions);
......@@ -283,17 +275,9 @@ class media_videojs_plugin extends core_media_player_native {
}
$extensions = $this->get_supported_extensions();
$rtmpallowed = get_config('media_videojs', 'rtmp') && get_config('media_videojs', 'useflash');
foreach ($urls as $url) {
// If RTMP support is disabled, skip the URL that is using RTMP (which
// might have been picked to the list by its valid extension).
if (!$rtmpallowed && ($url->get_scheme() === 'rtmp')) {
continue;
}
// If RTMP support is allowed, URL with RTMP scheme is supported irrespective to extension.
if ($rtmpallowed && ($url->get_scheme() === 'rtmp')) {
$result[] = $url;
// Skip the URL that is using RTMP (which might have been picked to the list by its valid extension).
if ($url->get_scheme() === 'rtmp') {
continue;
}
......@@ -305,15 +289,7 @@ class media_videojs_plugin extends core_media_player_native {
continue;
}
if (!get_config('media_videojs', 'useflash')) {
return parent::list_supported_urls($urls, $options);
} else {
// If Flash fallback is enabled we can not check if/when browser supports flash.
// We assume it will be able to handle any other extensions that player supports.
if (in_array($ext, $extensions)) {
$result[] = $url;
}
}
return parent::list_supported_urls($urls, $options);
}
return $result;
}
......@@ -381,9 +357,6 @@ class media_videojs_plugin extends core_media_player_native {
if (get_config('media_videojs', 'youtube')) {
$supports .= ($supports ? '<br>' : '') . get_string('youtube', 'media_videojs');
}
if (get_config('media_videojs', 'rtmp') && get_config('media_videojs', 'useflash')) {
$supports .= ($supports ? '<br>' : '') . get_string('rtmp', 'media_videojs');
}
return $supports;
}
......@@ -393,10 +366,6 @@ class media_videojs_plugin extends core_media_player_native {
if (get_config('media_videojs', 'youtube')) {
$markers = array_merge($markers, array('youtube.com', 'youtube-nocookie.com', 'youtu.be', 'y2u.be'));
}
// Add RTMP support if enabled.
if (get_config('media_videojs', 'rtmp') && get_config('media_videojs', 'useflash')) {
$markers[] = 'rtmp://';
}
return $markers;
}
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* VideoJS media player upgrade code
*
* This file keeps track of upgrades to
* the videojs media player.
*
* Sometimes, changes between versions involve
* alterations to database structures and other
* major things that may break installations.
*
* The upgrade function in this file will attempt
* to perform all the necessary actions to upgrade
* your older installation to the current version.
*
* If there's something it cannot do itself, it
* will tell you what you need to do.
*
* The commands in here will all be database-neutral,
* using the methods of database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @package media_videojs
* @copyright 2021 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
/**
* Main upgrade tasks to be executed on plugin version bump.
*
* @param int $oldversion
* @return bool always true
*/
function xmldb_media_videojs_upgrade($oldversion) {
global $CFG;
if ($oldversion < 2021052503) {
// Remove useflash and rtmp settings.
unset_config('useflash', 'media_videojs');
unset_config('rtmp', 'media_videojs');
// Main savepoint reached.
upgrade_plugin_savepoint(true, 2021052503, 'media', 'videojs');
}
return true;
}
configrtmp,media_videojs
configuseflash,media_videojs
rtmp,media_videojs
useflash,media_videojs
......@@ -27,19 +27,21 @@ defined('MOODLE_INTERNAL') || die();
$string['audiocssclass'] = 'CSS class for audio';
$string['audioextensions'] = 'Audio file extensions';
$string['configaudiocssclass'] = 'A CSS class that will be added to the &lt;audio&gt; element.';
$string['configaudioextensions'] = 'A comma-separated list of supported audio file extensions. VideoJS will try to use the browser\'s native video player when available or native VideoJS functionality, and fall back to a Flash player for other formats if Flash is supported by the browser and Flash fallback is enabled below.';
$string['configaudioextensions'] = 'A comma-separated list of supported audio file extensions. VideoJS will try to use the browser\'s native video player when available or native VideoJS functionality.';
$string['configlimitsize'] = 'If enabled, and width and height are not specified, the video will display with default width and height. Otherwise it will stretch to the maximum possible width.';
$string['configrtmp'] = 'If enabled, links that start with rtmp:// will be handled by the plugin, irrespective of whether the extension is enabled in the Video file extensions (videoextensions) setting. Flash fallback must be enabled for RTMP to work.';
$string['configvideocssclass'] = 'A CSS class that will be added to the &lt;video&gt; element. For example, the CSS class "vjs-big-play-centered" will place the play button in the middle. For details, including how to set a custom skin, see docs.videojs.com.';
$string['configvideoextensions'] = 'A comma-separated list of supported video file extensions. VideoJS will try to use the browser\'s native video player when available, and fall back to a Flash player for other formats if Flash is supported by the browser and Flash fallback is enabled below.';
$string['configvideoextensions'] = 'A comma-separated list of supported video file extensions. VideoJS will try to use the browser\'s native video player when available.';
$string['configyoutube'] = 'Use VideoJS to play YouTube videos. Note that YouTube playlists are not yet supported by VideoJS.';
$string['configuseflash'] = 'Use Flash player if video format is not natively supported by the browser and/or natively by the VideoJS player. If enabled, VideoJS will be engaged for any file extension from the above list without browser check. Please note that Flash is not available in mobile browsers and discouraged in many desktop ones.';
$string['limitsize'] = 'Limit size';
$string['pluginname'] = 'VideoJS player';
$string['pluginname_help'] = 'A JavaScript wrapper for video files played by the browser\'s native video player with a Flash player fallback. (Format support depends on the browser.)';
$string['pluginname_help'] = 'A JavaScript wrapper for video files played by the browser\'s native video player. (Format support depends on the browser.)';
$string['privacy:metadata'] = 'The VideoJS player media plugin does not store any personal data.';
$string['rtmp'] = 'RTMP streams';
$string['videoextensions'] = 'Video file extensions';
$string['useflash'] = 'Use Flash fallback';
$string['videocssclass'] = 'CSS class for video';
$string['youtube'] = 'YouTube videos';
// Deprecated since Moodle 4.0.
$string['configrtmp'] = 'If enabled, links that start with rtmp:// will be handled by the plugin, irrespective of whether the extension is enabled in the Video file extensions (videoextensions) setting. Flash fallback must be enabled for RTMP to work.';
$string['configuseflash'] = 'Use Flash player if video format is not natively supported by the browser and/or natively by the VideoJS player. If enabled, VideoJS will be engaged for any file extension from the above list without browser check. Please note that Flash is not available in mobile browsers and discouraged in many desktop ones.';
$string['rtmp'] = 'RTMP streams';
$string['useflash'] = 'Use Flash fallback';
......@@ -26,14 +26,3 @@ Import plugins:
define(['videojs']
with
define(['media_videojs/video-lazy']
2. Download the latest release from https://github.com/videojs/videojs-flash
Run "npm install"
Copy 'dist/videojs-flash.js' into 'amd/src/videojs-flash-lazy.js'
In the beginning of the js file replace
define(['videojs']
with
define(['media_videojs/video-lazy']
3. Download https://github.com/videojs/video-js-swf/blob/master/dist/video-js.swf
and place it into 'videojs/video-js.swf'
\ No newline at end of file
......@@ -38,14 +38,6 @@ if ($ADMIN->fulltree) {
'html_audio',
array('onlytypes' => array('audio', 'web_audio', 'html_audio'))));
$settings->add(new admin_setting_configcheckbox('media_videojs/rtmp',
new lang_string('rtmp', 'media_videojs'),
new lang_string('configrtmp', 'media_videojs'), 0));
$settings->add(new admin_setting_configcheckbox('media_videojs/useflash',
new lang_string('useflash', 'media_videojs'),
new lang_string('configuseflash', 'media_videojs'), 0));
$settings->add(new admin_setting_configcheckbox('media_videojs/youtube',
new lang_string('youtube', 'media_videojs'),
new lang_string('configyoutube', 'media_videojs'), 1));
......
......@@ -22,7 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace media_videojs;
use core_media_manager;
use html_writer;
use media_videojs_plugin;
use moodle_url;
/**
* Test script for media embedding.
......@@ -31,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class media_videojs_player_testcase extends advanced_testcase {
class player_test extends \advanced_testcase {
/**
* Pre-test setup. Preserves $CFG.
......@@ -46,7 +51,7 @@ class media_videojs_player_testcase extends advanced_testcase {
\core\plugininfo\media::set_enabled_plugins('videojs');
// Pretend to be using Firefox browser (must support ogg for tests to work).
core_useragent::instance(true, 'Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0 ');
\core_useragent::instance(true, 'Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0 ');
}
/**
......@@ -64,8 +69,6 @@ class media_videojs_player_testcase extends advanced_testcase {
$supportedextensions = array_merge(file_get_typegroup('extension', 'html_video'),
file_get_typegroup('extension', 'html_audio'), file_get_typegroup('extension', 'media_source'));
set_config('useflash', 0, 'media_videojs');
// Make sure that the list of extensions from the setting is filtered to HTML5 natively supported extensions.
$player = new media_videojs_plugin();
$this->assertTrue(in_array('.mp3', $player->get_supported_extensions()));
......@@ -79,18 +82,11 @@ class media_videojs_player_testcase extends advanced_testcase {
$this->assertFalse(in_array('.ra', $player->get_supported_extensions()));
$this->assertEmpty(array_diff($player->get_supported_extensions(), $supportedextensions));
// Try to use flash extensions and make sure they are not returned as supported.
// Check flash extensions are not returned as supported.
set_config('videoextensions', '.flv,.f4v', 'media_videojs');
$player = new media_videojs_plugin();
$this->assertFalse(in_array('.flv', $player->get_supported_extensions()));
$this->assertFalse(in_array('.f4v', $player->get_supported_extensions()));
// Enable flash and test if flash extenstions are supported.
set_config('useflash', 1, 'media_videojs');
set_config('videoextensions', '.flv,.f4v', 'media_videojs');
$player = new media_videojs_plugin();
$this->assertTrue(in_array('.flv', $player->get_supported_extensions()));
$this->assertTrue(in_array('.f4v', $player->get_supported_extensions()));
}
/**
......@@ -259,7 +255,6 @@ class media_videojs_player_testcase extends advanced_testcase {
*/
public function test_youtube() {
set_config('youtube', 1, 'media_videojs');
set_config('useflash', 0, 'media_videojs');
$manager = core_media_manager::instance();
......@@ -316,7 +311,6 @@ class media_videojs_player_testcase extends advanced_testcase {
*/
public function test_youtube_start_time(string $url, int $expectedstart) {
set_config('youtube', 1, 'media_videojs');
set_config('useflash', 0, 'media_videojs');
$embedcode = core_media_manager::instance()->embed_url(new moodle_url($url));
......@@ -335,23 +329,11 @@ class media_videojs_player_testcase extends advanced_testcase {
}
/**
* Test that VideoJS can embed flash videos.
* Test that VideoJS can not embed flash videos.
*/
public function test_flash() {
public function test_flash_behaviour() {
$manager = core_media_manager::instance();
// Flash enabled.
set_config('useflash', 1, 'media_videojs');
$url = new moodle_url('http://example.org/some_filename.flv');
$t = $manager->embed_url($url);
$this->flash_plugin_engaged($t);
$this->assertMatchesRegularExpression('~</video>~', $t);
$this->assertMatchesRegularExpression('~<source src="http://example.org/some_filename.flv"~', $t);
$this->assertMatchesRegularExpression(
'~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
// Flash disabled.
set_config('useflash', 0, 'media_videojs');
$url = new moodle_url('http://example.org/some_filename.flv');
$t = $manager->embed_url($url);
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
......@@ -360,51 +342,15 @@ class media_videojs_player_testcase extends advanced_testcase {
}
/**
* Test that VideoJS can embed RTMP streams.
* Test that VideoJS can not embed RTMP streams.
*/
public function test_rtmp() {
public function test_rtmp_behaviour() {
$manager = core_media_manager::instance();
// RTMP disabled, flash disabled.
set_config('useflash', 0, 'media_videojs');
set_config('rtmp', 0, 'media_videojs');
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
$t = $manager->embed_url($url);
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
$this->assertMatchesRegularExpression(
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
// RTMP enabled, flash disabled.
set_config('useflash', 0, 'media_videojs');
set_config('rtmp', 1, 'media_videojs');
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
$t = $manager->embed_url($url);
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
$this->assertMatchesRegularExpression(
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
// RTMP enabled, flash enabled, rtmp/mp4 type expected.
set_config('useflash', 1, 'media_videojs');
set_config('rtmp', 1, 'media_videojs');
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
$t = $manager->embed_url($url);
$this->flash_plugin_engaged($t);
$this->assertMatchesRegularExpression('~</video>~', $t);
$this->assertMatchesRegularExpression(
'~<source src="rtmp://example.com/fms&mp4:path/to/file.mp4" type="rtmp/mp4"~', $t);
$this->assertMatchesRegularExpression(
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
// RTMP enabled, flash enabled, rtmp/flv type expected.
set_config('useflash', 1, 'media_videojs');
set_config('rtmp', 1, 'media_videojs');
$url = new moodle_url('rtmp://example.com/fms&flv:path/to/file.flv');
$t = $manager->embed_url($url);
$this->flash_plugin_engaged($t);
$this->assertMatchesRegularExpression('~</video>~', $t);
$this->assertMatchesRegularExpression(
'~<source src="rtmp://example.com/fms&flv:path/to/file.flv" type="rtmp/flv"~', $t);
$this->assertMatchesRegularExpression(
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&flv:path/to/file.flv">file.flv</a>~', $t);
}
}
......@@ -21,18 +21,4 @@
<version>7.10.0</version>
<licenseversion>2.0</licenseversion>
</library>
<library>
<location>amd/src/videojs-flash-lazy.js</location>
<name>The Flash tech for video.js </name>
<license>Apache</license>
<version>2.2.1</version>
<licenseversion>2.0</licenseversion>
</library>
<library>
<location>videojs/video-js.swf</location>
<name>Custom Flash Player for VideoJS</name>
<license>Apache</license>
<version>5.4.2</version>
<licenseversion>2.0</licenseversion>
</library>
</libraries>
......@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2021052502; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021052503; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'media_videojs'; // Full name of the plugin (used for diagnostics).
Copyright Brightcove, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
This files describes API changes in /media/ plugins,
information provided here is intended especially for developers.
=== 4.0 ===
* The videojs-flash-lazy.js and videojs/video-js-swf libraries have been removed, because the Flash Player was deprecated
in 2017 and officially discontinued on 31 December 2020. Besides, the rtmp and useflash settings have been removed because
they are not required anymore, now that the flash support has been removed from the videojs media player.
=== 3.8 ===
* The final deprecation of core_media_manager::setup() means that this function will no longer be called.
The setup is now done in ::instance() so there is no need to call this.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment