Loading a videojs plugin (videojs-record)

Hello everyone,

Im trying to get videojs-record into a plugin. Videojs is not designed to work as AMD, and it seems the record plugin is not accesible by videojs when it is loaded asyncronously.

Everytime Im getting the error: 'Uncaught Error: plugin "record" does not exist'.

Checking the network, the plugin and all dependencies are loaded properly. This is my code:

In views.php

<?php // views.php

 

return [
    // viewtype
    "default" => [
        // view => path
        'js/' => __DIR__.'/vendor/node_modules',
    ],
];

 

In  start.php

    elgg_define_js('video_js', [
        'src' => elgg_get_simplecache_url('js/video.js/dist/video.min.js&#39;),
 
        'exports' => 'videojs',
    ]);
    elgg_define_js('record_rtc', [
        'src' => elgg_get_simplecache_url('js/recordrtc/RecordRTC.js'),
        'exports' => 'RecordRTC',
    ]);
    elgg_define_js('adapter', [
        'src' => elgg_get_simplecache_url('js/webrtc-adapter/out/adapter.js'),
        'exports' => 'adapter',
    ]);
    elgg_define_js('record', [
        'src' => elgg_get_simplecache_url('js/videojs-record/dist/videojs.record.js'),
        'exports' => 'record',
    ]);

 In main.js (which is added in views/add with elgg_require_js)

requirejs.config ({
    paths: {
        ellipse: 'js/ellipse',
        card_selected1: 'js/card_selected1',
        card_selected2: 'js/card_selected2',
        edit_post: 'js/edit_post',
        dovideo: 'js/dovideo',
        video_js: 'js/video.js/dist/video&#39;,
        record_rtc: 'js/recordrtc/RecordRTC',
        adapter: 'js/webrtc-adapter/out/adapter',
        record: [
            'js/videojs-record/dist/videojs.record',
        ],
    },
    shim: {
        record: {
            deps: ['videojs','adapter','RecordRTC'],
            exports: 'record',
        },
        video_js: {
            exports: 'videojs',
        }
    },
    waitSeconds: 0,
});

 

require(["jquery","card_selected1","card_selected2","edit_post""elgg","dovideo","video_js"], function($card_selected1card_selected2edit_postelgg,dovideo,videojs) {
// Stuff
});

 

 

and in dovideo.js, which is called asyncronously by main.js

define(function(require) {
    var elgg = require("elgg");
    var $ = require("jquery");
    var window = require("global/window");
    var videojs = require("video_js");
    var RecordRTC = require("record_rtc");
    var adapter = require("adapter");
    var Record = require("record");

 

    $(function(){
        alert('dovideo');
        var videoMaxLengthInSeconds = 120;

 

        // Inialize the video player
        var player = videojs("myVideo", {
            controls: true,
            width: 720,
            height: 480,
            fluid: true,
            plugins: {
                record: {
                    audio: true,
                    video: true,
                    maxLength: videoMaxLengthInSeconds,
                    debug: true,
                    videoMimeType: "video/webm;codecs=H264"
                }
            }
        }, function(){
            // print version information at startup
            videojs.log(
                'Using video.js'videojs.VERSION,
                'with videojs-record'videojs.getPluginVersion('record'),
                'and recordrtc'RecordRTC.version
            );
        });
});
});

 

If anyone has an insight about this I would be grateful.

Thank you!