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

getting error : the player has already been destroyed. #8

Open
smartraysam opened this issue Oct 20, 2024 · 0 comments
Open

getting error : the player has already been destroyed. #8

smartraysam opened this issue Oct 20, 2024 · 0 comments

Comments

@smartraysam
Copy link

{
"code": 1001,
"name": "API_NOT_AVAILABLE",
"message": "Cannot use the player.isCasting API: the player has already been destroyed."
}

Am alway getting this error. kindly help on way to resolve this>

here is my code

`
import { LogLevel, PlayerAPI, PlayerEvent } from "bitmovin-player";
import { BitmovinPlayer } from "bitmovin-player-react";
import { Fragment, useEffect, useRef, useState } from "react";
import "bitmovin-player/bitmovinplayer-ui.css";

export function ContentPlayer({
id,
autoplay,
media,
height,
poster,
stop,
}: {
id?: string; // Unique ID for each player instance
autoplay?: boolean;
media: string;
height?: number | string;
poster?: string;
stop?: boolean;
}) {
const playerRef = useRef<PlayerAPI | null>(null);
const [isPlaying, setIsPlaying] = useState(stop);
useEffect(() => {
if (stop) {
setIsPlaying(stop);
}
}, [stop]);
return (

<div
id={id}
style={{
position: "relative",
maxWidth: "100%",
height: height || "512px",
minHeight: "512px",
background: "black",
display: "flex",
justifyContent: "center",
flexDirection: "column",
}}
>
<BitmovinPlayer
key={id}
playerRef={(player: PlayerAPI) => {
playerRef.current = player;
if (player) {
if (!isPlaying) {
if (player.isPlaying()) {
player.pause();
}
}
}
player.on(PlayerEvent.Play, () => {});
player.on(PlayerEvent.Paused, () => {});
player.on(PlayerEvent.PlaybackFinished, () => {
player.seek(0);
});
}}
source={{
hls: media,
poster: poster,
}}
config={{
key: process.env.NEXT_PUBLIC_BITMOVIN_KEY!,
playback: {
muted: autoplay ?? false, // Mute if autoplay is enabled
autoplay: autoplay ?? false,
seeking: true,
},
logs: {
level: LogLevel.OFF, // Disable all logs
},
ui: true
}}
/>


);
}

`

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