What is the best way to embed videos from the Facebook Graph API?

I am trying to show a video that came back from Facebook Graph Api. I have a video source, which is YouTube video, Vimeo video, Facebook video, or any other type of video that is sent to the news feed.

My $ facebookdata returns this:

[source] => http://www.youtube.com/v/PwD4t9gcLb4?version=3&autohide=1&autoplay=1 

I set the value of SOURCE to $ status_video_embed as follows:

 $status_video_embed = str_replace("autoplay=1", "autoplay=0", $data['source']); 

In addition, you can see that I am replacing auto play with 0 if it exists.

I inserted a video to display as follows:

 echo '<iframe src="' . $status_video_embed . '" type="text/html" allowscriptaccess="always" allowfullscreen="true" width="350" height="197"></iframe>'; 

This works, but I run into a few problems. Firstly, if this video is different from the video on Facebook, it works fine, but I can't make it fullscreen. I assume this is due to the fact that it is being implemented in an iFrame. The second problem is uploading videos to Facebook, they automatically start, and I can’t figure out how to prevent these videos from playing automatically.

The second approach I made is as follows:

 echo '<object width="350" height="197" ><param name="allowfullscreen" value="true" />'; echo '<param name="movie" value="' . $status_video_embed . '" />'; echo '<embed src="' . $status_video_embed . '" type="application/x-shockwave-flash" allowfullscreen="true" width="350" height="197"></embed>'; echo '</object>'; 

This displays the video, except that they are downloaded and displayed forever - this prevents the video from automatically playing on facebook, but now when I click the play button on any video, nothing happens. No controls through the embedded video work.

Does anyone know what is the best way to embed video in this method? I have been given the source of the video from the returned array.

I hope someone can help, thanks.

+4
source share
1 answer

Why don't you create your own player in HTML5 and parse the video page for a URL?

-2
source

Source: https://habr.com/ru/post/1446732/


All Articles