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

After upgrading the video js version to 8.21.0, the.mpd file cannot be played normally in chrome, but can be played normally in safari. #8966

Open
sitaoi opened this issue Jan 23, 2025 · 1 comment

Comments

@sitaoi
Copy link

sitaoi commented Jan 23, 2025

After upgrading the video js version to 8.21.0, the.mpd file cannot be played normally in chrome, but can be played normally in safari. The error message is as follows: Playback cannot continue. No available working or supported playlists.

@sitaoi
Copy link
Author

sitaoi commented Jan 23, 2025

'use client';

import { useEffect, useRef } from 'react';
import dynamic from 'next/dynamic';
import videojs from 'video.js'
import 'video.js/dist/video-js.css'

interface VideoPlayerProps {
src: string;
}

const VideoPlayer = ({ src }: VideoPlayerProps) => {
const videoRef = useRef<HTMLVideoElement | null>(null);
const playerRef = useRef(null);

useEffect(() => {
require('videojs-contrib-dash');
require('dashjs')
},[])
useEffect(() => {
const setupPlayer = async () => {
await require('videojs-contrib-dash');
await require('dashjs');

  if (videoRef.current && !playerRef.current) {
    const player = videojs(videoRef.current, {
      controls: true,
      fluid: true,
      html5: {
        dash: {
          limitBitrateByPortal: true,
          useDashJS: true,
          overrideNative: true,
          fastSwitchEnabled: true,  // 添加快速切换支持
          lowLatencyEnabled: false, // 禁用低延迟模式
          abr: {
            enabled: true,
            useDefaultABRRules: true
          }
        },
        nativeAudioTracks: false,
        nativeVideoTracks: false,
        nativeTextTracks: false
      },
      crossorigin: "anonymous",
    });

    player.on('error', function() {
      const error = player.error();
      console.log('Video Error:', error);
    });

    playerRef.current = player;

    if (src) {
      player.src({
        src: src,
        type: 'application/dash+xml',
        withCredentials: false
      });
    }
  }
};

setupPlayer();

return () => {
  if (playerRef.current) {
    playerRef.current.dispose();
    playerRef.current = null;
  }
};

}, [src]);

return (



);
};

export default dynamic(() => Promise.resolve(VideoPlayer), {
ssr: false
});

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