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

建议flvjs的事件集成到videojs中 #27

Open
JinZhang-96 opened this issue Jul 6, 2022 · 0 comments
Open

建议flvjs的事件集成到videojs中 #27

JinZhang-96 opened this issue Jul 6, 2022 · 0 comments

Comments

@JinZhang-96
Copy link

setSrc(src) {
if (this.flvPlayer) {
// Is this necessary to change source?
this.flvPlayer.detachMediaElement();
this.flvPlayer.destroy();
}

const mediaDataSource = this.options_.mediaDataSource;
const config = this.options_.config;

mediaDataSource.type = mediaDataSource.type === undefined ? 'flv' : mediaDataSource.type;
mediaDataSource.url = src;
this.flvPlayer = window.flvjs.createPlayer(mediaDataSource, config);
this.bindEvent();
this.flvPlayer.attachMediaElement(this.el_);
this.flvPlayer.load();

}

/**

  • 绑定flv事件
    */
    bindEvent() {
    const player = videojs.getPlayer(this.options().playerId);
    if (!this.flvPlayer || !player) return;
    // 【flvjs播放器事件侦听】
    for (const type in window.flvjs.Events) {
    this.flvPlayer.on(window.flvjs.Events[type], function () {
    player.trigger({
    type: window.flvjs.Events[type],
    data: arguments
    });
    });
    }
    }
    }
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

No branches or pull requests

1 participant