Reputation: 99
I am using react-elastic-carousel
and reactjs-media
npm packages to display a carousel of youtube videos . However my videos do not show up and if I click on one I get "Error appeared . Try again later "
My code :
VideoSlider.js
import Carousel from "react-elastic-carousel";
import {YoutubePlayer} from 'reactjs-media';
export default function VideoSlider() {
const links = [
'https://www.youtube.com/watch?v=_ng_bVJMm88',
'https://www.youtube.com/watch?v=5Zmx5D7dOYA&feature=emb_title',
'https://www.youtube.com/watch?v=nKzXUTvn2es',
'https://www.youtube.com/watch?v=Wk97ev-M2Nw',
'https://www.youtube.com/watch?v=FZta8t2L1pk',
'https://www.youtube.com/watch?v=BOmSrKRWJS0',
]
const breakPoints = [
{ width: 1, itemsToShow: 1 },
{ width: 550, itemsToShow: 2, itemsToScroll: 2 },
{ width: 768, itemsToShow: 2 },
{ width: 1200, itemsToShow: 3 }
];
return (
<div className="bg-FQAItem h-84 p-4">
<div className="carousel-wrapper">
<Carousel breakPoints={breakPoints} isRTL ={false} >
{links.map((item,index) => (
<YoutubePlayer src="https://www.youtube.com/watch?v=5Zmx5D7dOYA&feature=emb_title" height={350} key = {index}/>
))}
</Carousel>
</div>
</div>
)
}
I would appreciate your help with this .
Upvotes: 1
Views: 1032
Reputation: 1006
Your video link url is wrong.
Correct URL should be -> https://youtu.be/5Zmx5D7dOYA
instead of
https://www.youtube.com/watch?v=5Zmx5D7dOYA&feature=emb_title
It is recommended that video links should be taken by right-clicking on the video instead of copying from the browser address bar.
Refer: SRC prop note here --> https://cranom.com/reactjs-media/api/youtube-player-props
Upvotes: 3