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 { ...@@ -36,7 +36,6 @@ class filter_mediaplugin_testcase extends advanced_testcase {
// We need to enable the media plugins. // We need to enable the media plugins.
\core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5video,html5audio'); \core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5video,html5audio');
set_config('useflash', true, 'media_videojs');
$filterplugin = new filter_mediaplugin(null, array()); $filterplugin = new filter_mediaplugin(null, array());
...@@ -59,7 +58,6 @@ class filter_mediaplugin_testcase extends advanced_testcase { ...@@ -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://youtu.be/JghQgA2HMX8" class="href=css">test file</a>',
'<a href="http://y2u.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="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="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 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>', '<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 @@ ...@@ -24,7 +24,6 @@
*/ */
import Ajax from 'core/ajax'; import Ajax from 'core/ajax';
import Config from 'core/config';
import {eventTypes} from 'core_filters/events'; import {eventTypes} from 'core_filters/events';
import LocalStorage from 'core/localstorage'; import LocalStorage from 'core/localstorage';
import Notification from 'core/notification'; import Notification from 'core/notification';
...@@ -88,14 +87,10 @@ const notifyVideoJS = e => { ...@@ -88,14 +87,10 @@ const notifyVideoJS = e => {
// Add YouTube to the list of modules we require. // Add YouTube to the list of modules we require.
modulePromises.push(import('media_videojs/Youtube-lazy')); 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]) Promise.all([langStrings, ...modulePromises])
.then(([langJson, videojs]) => { .then(([langJson, videojs]) => {
if (firstLoad) { 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.playbackRates = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
videojs.options.userActions = { videojs.options.userActions = {
hotkeys: true, hotkeys: true,
......
/**
* videojs-flash
* @version 2.2.1
* @copyright 2020 Brightcove, Inc.
* @license Apache-2.0
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js')) :
typeof define === 'function' && define.amd ? define(['media_videojs/video-lazy'], factory) :
(global.videojsFlash = factory(global.videojs));
}(this, (function (videojs) { 'use strict';
videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs;
var version = "5.4.2";
var version$1 = "2.2.1";
/**
* @file flash-rtmp.js
* @module flash-rtmp
*/
/**
* Add RTMP properties to the {@link Flash} Tech.
*
* @param {Flash} Flash
* The flash tech class.
*
* @mixin FlashRtmpDecorator
*
* @return {Flash}
* The flash tech with RTMP properties added.
*/
function FlashRtmpDecorator(Flash) {
Flash.streamingFormats = {
'rtmp/mp4': 'MP4',
'rtmp/flv': 'FLV'
};
/**
* Join connection and stream with an ampersand.
*
* @param {string} connection
* The connection string.
*
* @param {string} stream
* The stream string.
*
* @return {string}
* The connection and stream joined with an `&` character
*/
Flash.streamFromParts = function (connection, stream) {
return connection + '&' + stream;
};
/**
* The flash parts object that contains connection and stream info.
*
* @typedef {Object} Flash~PartsObject
*
* @property {string} connection
* The connection string of a source, defaults to an empty string.
*
* @property {string} stream
* The stream string of the source, defaults to an empty string.
*/
/**
* Convert a source url into a stream and connection parts.
*
* @param {string} src
* the source url
*
* @return {Flash~PartsObject}
* The parts object that contains a connection and a stream
*/
Flash.streamToParts = function (src) {
var parts = {
connection: '',
stream: ''
};
if (!src) {
return parts;
}
// Look for the normal URL separator we expect, '&'.
// If found, we split the URL into two pieces around the
// first '&'.
var connEnd = src.search(/&(?![\w-]+=)/);
var streamBegin = void 0;
if (connEnd !== -1) {
streamBegin = connEnd + 1;
} else {
// If there's not a '&', we use the last '/' as the delimiter.
connEnd = streamBegin = src.lastIndexOf('/') + 1;
if (connEnd === 0) {
// really, there's not a '/'?
connEnd = streamBegin = src.length;
}
}
parts.connection = src.substring(0, connEnd);
parts.stream = src.substring(streamBegin, src.length);
return parts;
};
/**
* Check if the source type is a streaming type.
*
* @param {string} srcType
* The mime type to check.
*
* @return {boolean}
* - True if the source type is a streaming type.
* - False if the source type is not a streaming type.
*/
Flash.isStreamingType = function (srcType) {
return srcType in Flash.streamingFormats;
};
// RTMP has four variations, any string starting
// with one of these protocols should be valid
/**
* Regular expression used to check if the source is an rtmp source.
*
* @property {RegExp} Flash.RTMP_RE
*/
Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
/**
* Check if the source itself is a streaming type.
*
* @param {string} src
* The url to the source.
*
* @return {boolean}
* - True if the source url indicates that the source is streaming.
* - False if the shource url indicates that the source url is not streaming.
*/
Flash.isStreamingSrc = function (src) {
return Flash.RTMP_RE.test(src);
};
/**
* A source handler for RTMP urls
* @type {Object}
*/
Flash.rtmpSourceHandler = {};
/**
* Check if Flash can play the given mime type.
*
* @param {string} type
* The mime type to check
*
* @return {string}
* 'maybe', or '' (empty string)
*/
Flash.rtmpSourceHandler.canPlayType = function (type) {
if (Flash.isStreamingType(type)) {
return 'maybe';
}
return '';
};
/**
* Check if Flash can handle the source natively
*
* @param {Object} source
* The source object
*
* @param {Object} [options]
* The options passed to the tech
*
* @return {string}
* 'maybe', or '' (empty string)
*/
Flash.rtmpSourceHandler.canHandleSource = function (source, options) {
var can = Flash.rtmpSourceHandler.canPlayType(source.type);
if (can) {
return can;
}
if (Flash.isStreamingSrc(source.src)) {
return 'maybe';
}
return '';
};
/**
* Pass the source to the flash object.
*
* @param {Object} source
* The source object
*
* @param {Flash} tech
* The instance of the Flash tech
*
* @param {Object} [options]
* The options to pass to the source
*/
Flash.rtmpSourceHandler.handleSource = function (source, tech, options) {
var srcParts = Flash.streamToParts(source.src);
tech.setRtmpConnection(srcParts.connection);
tech.setRtmpStream(srcParts.stream);
};
// Register the native source handler
Flash.registerSourceHandler(Flash.rtmpSourceHandler);
return Flash;
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var win;
if (typeof window !== "undefined") {
win = window;
} else if (typeof commonjsGlobal !== "undefined") {
win = commonjsGlobal;
} else if (typeof self !== "undefined"){
win = self;
} else {
win = {};
}
var window_1 = win;
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
/**
* @file flash.js
* VideoJS-SWF - Custom Flash Player with HTML5-ish API
* https://github.com/zencoder/video-js-swf
* Not using setupTriggers. Using global onEvent func to distribute events
*/
var Tech = videojs.getComponent('Tech');
var Dom = videojs.dom;
var Url = videojs.url;
var createTimeRange = videojs.createTimeRange;
var mergeOptions = videojs.mergeOptions;
var navigator = window_1 && window_1.navigator || {};
/**
* Flash Media Controller - Wrapper for Flash Media API
*
* @mixes FlashRtmpDecorator
* @mixes Tech~SouceHandlerAdditions
* @extends Tech
*/
var Flash = function (_Tech) {
inherits(Flash, _Tech);
/**
* Create an instance of this Tech.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} ready
* Callback function to call when the `Flash` Tech is ready.
*/
function Flash(options, ready) {
classCallCheck(this, Flash);
// Set the source when ready
var _this = possibleConstructorReturn(this, _Tech.call(this, options, ready));
if (options.source) {
_this.ready(function () {
this.setSource(options.source);
}, true);
}
// Having issues with Flash reloading on certain page actions
// (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
if (options.startTime) {
_this.ready(function () {
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
window_1.videojs = window_1.videojs || {};
window_1.videojs.Flash = window_1.videojs.Flash || {};
window_1.videojs.Flash.onReady = Flash.onReady;
window_1.videojs.Flash.onEvent = Flash.onEvent;
window_1.videojs.Flash.onError = Flash.onError;
_this.on('seeked', function () {
this.lastSeekTarget_ = undefined;
});
return _this;
}
/**
* Create the `Flash` Tech's DOM element.
*
* @return {Element}
* The element that gets created.
*/
Flash.prototype.createEl = function createEl() {
var options = this.options_;
// If video.js is hosted locally you should also set the location
// for the hosted swf, which should be relative to the page (not video.js)
// Otherwise this adds a CDN url.
// The CDN also auto-adds a swf URL for that specific version.
if (!options.swf) {
options.swf = 'https://vjs.zencdn.net/swf/' + version + '/video-js.swf';
}
// Generate ID for swf object
var objId = options.techId;
// Merge default flashvars with ones passed in to init
var flashVars = mergeOptions({
// SWF Callback Functions
readyFunction: 'videojs.Flash.onReady',
eventProxyFunction: 'videojs.Flash.onEvent',
errorEventProxyFunction: 'videojs.Flash.onError',
// Player Settings
autoplay: options.autoplay,
preload: options.preload,
loop: options.loop,
muted: options.muted
}, options.flashVars);
// Merge default parames with ones passed in
var params = mergeOptions({
// Opaque is needed to overlay controls, but can affect playback performance
wmode: 'opaque',
// Using bgcolor prevents a white flash when the object is loading
bgcolor: '#000000'
}, options.params);
// Merge default attributes with ones passed in
var attributes = mergeOptions({
// Both ID and Name needed or swf to identify itself
id: objId,
name: objId,
'class': 'vjs-tech'
}, options.attributes);
this.el_ = Flash.embed(options.swf, flashVars, params, attributes);
this.el_.tech = this;
return this.el_;
};
/**
* Called by {@link Player#play} to play using the `Flash` `Tech`.
*/
Flash.prototype.play = function play() {
if (this.ended()) {
this.setCurrentTime(0);
}
this.el_.vjs_play();
};
/**
* Called by {@link Player#pause} to pause using the `Flash` `Tech`.
*/
Flash.prototype.pause = function pause() {
this.el_.vjs_pause();
};
/**
* A getter/setter for the `Flash` Tech's source object.
* > Note: Please use {@link Flash#setSource}
*
* @param {Tech~SourceObject} [src]
* The source object you want to set on the `Flash` techs.
*
* @return {Tech~SourceObject|undefined}
* - The current source object when a source is not passed in.
* - undefined when setting
*
* @deprecated Since version 5.
*/
Flash.prototype.src = function src(_src) {
if (_src === undefined) {
return this.currentSrc();
}
// Setting src through `src` not `setSrc` will be deprecated
return this.setSrc(_src);
};
/**
* A getter/setter for the `Flash` Tech's source object.
*
* @param {Tech~SourceObject} [src]
* The source object you want to set on the `Flash` techs.
*/
Flash.prototype.setSrc = function setSrc(src) {
var _this2 = this;
// Make sure source URL is absolute.
src = Url.getAbsoluteURL(src);
this.el_.vjs_src(src);
// Currently the SWF doesn't autoplay if you load a source later.
// e.g. Load player w/ no source, wait 2s, set src.
if (this.autoplay()) {
this.setTimeout(function () {
return _this2.play();
}, 0);
}
};
/**
* Indicates whether the media is currently seeking to a new position or not.
*
* @return {boolean}
* - True if seeking to a new position
* - False otherwise
*/
Flash.prototype.seeking = function seeking() {
return this.lastSeekTarget_ !== undefined;
};
/**
* Returns the current time in seconds that the media is at in playback.
*
* @param {number} time
* Current playtime of the media in seconds.
*/
Flash.prototype.setCurrentTime = function setCurrentTime(time) {
var seekable = this.seekable();
if (seekable.length) {
// clamp to the current seekable range
time = time > seekable.start(0) ? time : seekable.start(0);
time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
this.lastSeekTarget_ = time;
this.trigger('seeking');
this.el_.vjs_setProperty('currentTime', time);
_Tech.prototype.setCurrentTime.call(this);
}
};
/**
* Get the current playback time in seconds
*
* @return {number}
* The current time of playback in seconds.
*/
Flash.prototype.currentTime = function currentTime() {
// when seeking make the reported time keep up with the requested time
// by reading the time we're seeking to
if (this.seeking()) {
return this.lastSeekTarget_ || 0;
}
return this.el_.vjs_getProperty('currentTime');
};
/**
* Get the current source
*
* @method currentSrc
* @return {Tech~SourceObject}
* The current source
*/
Flash.prototype.currentSrc = function currentSrc() {
if (this.currentSource_) {
return this.currentSource_.src;
}
return this.el_.vjs_getProperty('currentSrc');
};
/**
* Get the total duration of the current media.