1

I have a input that user will place a youtube video link. After check if this is a youtube link I set state with this link.

this.setState({video: url});

inside render I have this:

var showVideo = "";
if(this.state.video != null) {
    showVideo = <iframe id="videoObject" type="text/html" src={this.state.video} width="500" title="video" height="265" frameborder="0" allowfullscreen></iframe>
}

and return:

{showVideo}

I try to place the video url inside src, but the video is broken (it doesnt show any video). Any ideas why? (the url is correct)

RGS
  • 4,062
  • 4
  • 31
  • 67

1 Answers1

1

it is because you got to embed the video in your state. url and embedded link is different you need to convert the url to embedded link so you can display in in iframe.

This helps you out to convert the link into enbedded code

Pavan Kalyan
  • 377
  • 1
  • 10