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

How to add a tip? #676

Open
nianhuayixiao opened this issue Apr 2, 2024 · 3 comments
Open

How to add a tip? #676

nianhuayixiao opened this issue Apr 2, 2024 · 3 comments

Comments

@nianhuayixiao
Copy link

hi,

If a certain Hikvision camera does not start or is not connected to the internet, which code will prompt on the front-end page?

v0.8.5

@CHN-STUDENT
Copy link

CHN-STUDENT commented Jun 17, 2024

我用 vue2 + element-ui 写的两个遮罩层 loading 和 loading Error

 setPlay(url) {
            // 检查 WebRtcStreamer 是否已加载并创建实例
            if (typeof WebRtcStreamer !== 'undefined') {
                const videoElement = document.getElementById('videoWrapper');
                if (!this.videoPlayerPlugin) {
                    this.videoPlayerPlugin = new WebRtcStreamer(videoElement, location.protocol + "//172.16.172.24:8000");
                }

                // 连接视频流
                this.videoPlayerPlugin.connect(url);

                // 设置计时器,如果10秒后未播放则认为播放失败
                const timer = setTimeout(() => {
                    this.loading = false;
                    this.loadingError = true;
                    videoElement.removeEventListener('playing', onPlaying);
                    // videoElement.setAttribute("controls", true); // 显示控制菜单
                }, 10000);

                // 播放成功的回调
                const onPlaying = () => {
                    clearTimeout(timer);
                    this.loading = false;
                    this.loadingError = false;
                    videoElement.removeAttribute("controls"); // 隐藏控制菜单
                };

                videoElement.addEventListener('playing', onPlaying);

                // 播放失败的回调
                this.videoPlayerPlugin.onError = (error) => {
                    console.error("WebRTC error: ", error);
                    clearTimeout(timer);
                    this.loading = false;
                    this.loadingError = true;
                    videoElement.setAttribute("controls", true); // 显示控制菜单
                };

            } else {
                this.loading = false;
                this.loadingError = true;
            }
        }

@CHN-STUDENT
Copy link

CHN-STUDENT commented Jun 18, 2024

@mpromonet hi,mpromonet could you give me some advice to use in my vue project? our old project only use vue2, i try to use your project instead of RTMP(flash), I want to know how can i optimize and learn more.

@mpromonet
Copy link
Owner

Hi @CHN-STUDENT

Your post seems without any link with the initial issue. Please try to avoid to mix different subjects. To answer to your question using vuejs2 or vuejs3 or vanilla or another framework should be the same.
Best Regards
Michel

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

3 participants