I have the following object list:
mediaList[
{id:1, url:www.example.com/image1, adType:image/jpeg},
{id:2, url:www.example.com/image2, adType:image/jpg},
{id:3, url:www.example.com/video1, adType: video/mp4}
]
I need to create a slideshow that has a configurable duration (1s, 5, 10s).
So far I can generate a list of the media from the mediaList
renderSlideshow(ad){
let adType =ad.adType;
if(type.includes(image)){
return(
<div className=imagePreview>
<img src={ad.url} />
</div>
);
}else if (adType.includes(video)){
return(
<video className=videoPreview controls>
<source src={ad.url} type={adType}/>
Your browser does not support the video tag.
</video>
)
}
}
render(){
return(
<div>
{this.props.mediaList.map(this.renderSlideshow.bind(this))}
</div>
)
}
What I want to do now is generate the media one at a time with configurable durations for autoplay.
I know I need to use some form of a setTimeout function like this example:
setTimeout(function(){
this.setState({submitted:false});
}.bind(this),5000); // wait 5 seconds, then reset to false
I'm just not sure how to implement it for this scenario. (I believe I'll need to use css for the fade transitions but I'm just stumped on how to create the transition in the first place)