Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setAudioInput is broken when used in non AUDIO_ONLY mode #732

Open
restless opened this issue Sep 27, 2024 · 0 comments · May be fixed by #733
Open

setAudioInput is broken when used in non AUDIO_ONLY mode #732

restless opened this issue Sep 27, 2024 · 0 comments · May be fixed by #733

Comments

@restless
Copy link

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

@restless restless linked a pull request Sep 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant