Skip to content

setAudioInput is broken when used in non AUDIO_ONLY mode #732

Open
@restless

Description

@restless

Description

The setAudioInput method raises "player is not defined" exception when used in a mode different from the AUDIO_ONLY one.

The problematic code is the default case (videojs.record.js::Record.setAudioOutput) that expects global player to exist:

    setAudioOutput(deviceId) {
        let errorMessage;
        switch (this.getRecordType()) {
            case AUDIO_ONLY:
                // use wavesurfer
                (...)
            default:
                let element = player.tech_.el_;
                (...)

Steps to reproduce

I. Start with the "Change video input" example: https://github.com/collab-project/videojs-record/blob/master/examples/change-video-input.html

II. Change:

a) plugins.record.audio: false to plugins.record.audio: true in the options:

var options = {
    controls: true,
    width: 320,
    height: 240,
    fluid: false,
    bigPlayButton: false,
    controlBar: {
        volumePanel: false
    },
    plugins: {
        record: {
            audio: true,
            video: true,
            maxLength: 20,
            debug: true
        }
    }
};

b) videoinput to audiooutput in the enumerateReady handler's body:

if (deviceInfo.kind === 'audiooutput') {

c) setVideoInput to setAudioOutput in the changeVideoInput method:

player.record().setAudioOutput(deviceId);

d) rename player to something else, like myplayer

var myplayer = videojs(...)

The thing is that we don't want to create a global player here. In my case I use videojs-record with JS bundler and have no globals like that.

Results

Expected

Output device is changed to the newly selected one

Actual

Output device is not changed and an exception is raised due to the player being undefined

Error output

ReferenceError: player is not defined
    setAudioOutput http://localhost:8082/dist/videojs.record.js:3449
    changeVideoInput http://localhost:8082/change-audio-output-audiovideo-mode.html:134

Additional Information

Same issue was reported a while ago: #649

versions

videojs

VIDEOJS: Using video.js 8.10.0 with videojs-record 4.8.0 and recordrtc 5.6.2

browsers

Tested on FF and Vivaldi but I believe all browsers are affected

OSes

Tested on PopOs but I believe all systems are affected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions