添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
苦闷的水龙头  ·  Home - ISS World·  2 天前    · 
幸福的领结  ·  [Bug]: Edgecolor ...·  昨天    · 
很酷的脆皮肠  ·  How To Work with the ...·  1小时前    · 
玩命的莴苣  ·  President Zhao ...·  1小时前    · 
沉稳的草稿本  ·  Mulitilayer ...·  1 年前    · 

userAction.click doesn't work #7875

Closed
Closed
@strange-qwq

Description

Description

I set the execution function of the userActions.click event in the options, but it does not execute after I click the video box, how can I solve it?

In addition, I tried to add an error event to the ready function before, because I needed to deal with it after it failed to play, but it didn't take effect, so I can only change it to a waiting event now, however, It also will be executed when the network environment is poor. Is there any other event that can be replaced?

Reduced test case

No response

Steps to reproduce

this is a vite 3.0.3 project
1.create project
2.add component

<template>
    <div class="player-video overflow-x-hidden">
        <video :id="id" class="player-video-box">
            <source :src="url" type="application/x-mpegURL" />
        </video>
</template>
<script>
import videojs from 'video.js';
import { onUnmounted, reactive, toRefs, watch } from 'vue';
export default {
    props: {
        isPlaying: {
            type: Boolean,
            default: false
        id: {
            type: String,
            default: `player-video-box-${new Date().getTime()}`
        height: {
            type: [Number, String],
            required: true
        url: {
            type: String,
            required: true
    setup(props, { emit }) {
        const data = reactive({
            isMounted: false,
            player: null
        watch(() => props.height, () => {
            if (props.height > 0)
                if (!data.isMounted) methods.setVideo(props.id, props.height);
                else data.player.height(props.height);
        onUnmounted(() => {
            if(data.player) data.player.dispose();
        const methods = {
            setVideo(id, height) {
                console.log(id);
                data.isMounted = true;
                data.player = videojs(id, {
                    height: height,
                    loop: true,
                    autoplay: true,
                    controls: false,
                    preload: 'auto',
                    notSupportedMessage: 'Play failed, please check your network connection and try again later',
                    userActions: {
                        doubleClick: false,
                        click: function(_) {
                            console.log('click', this);
                            if (this.isFullscreen()) this.exitFullscreen();
                            else this.requestFullscreen();
                }, function () {
                    this.on('playing', function () {
                        console.log('onplaying');
                        emit('update:isPlaying', true);
                    this.on('waiting', function () {
                        console.log('onwaiting');
                        emit('update:isPlaying', false);
                    this.on('error', function (e) {
                        console.log('onerror', e);
        return { ...toRefs(data), ...methods, ...props };
</script>
<style lang="scss" scoped>
.player-video {
  position: relative;
:deep(.vjs-control-text) {
  display: none;
</style>

3.using components

<template>
    <div class="sentry-video">
                v-for="(key, index) of liveList"
                :key="index"
            <PlayerVideo v-model:isPlaying="key.isPlaying"
                         :id="`sentry-video-item-${index}`"
                         :url="key.url"
                         :height="videoHeight"
</template>

Errors

nothing

What version of Video.js are you using?

7.20.2

Video.js plugins used.

No response

What browser(s) including version(s) does this occur with?

Microsoft Edge 105.0.1343.4 dev (x64)

What OS(es) and version(s) does this occur with?

Windows 11