The solution is probably very simple, but still, I am struggling to understand how to make it work.
We are preparing for the new school year, and of course, we're required to make things work remotely. We will have a bunch of educational videos posted on Youtube, and an external Windows app will make sure everything is well organized and that teachers can easily upload new videos (via Youtube API), and that teachers can quickly share material to students.
And, when a teacher wants to send a video to students, he will obviously give them a link. They decided that they want videos to be played outside Youtube (for a number of reasons).
We have a WordPress website that is already functional, and which we can use to display Youtube videos that we can embed.
A WordPress page would have embed code for Youtube player, which is provided by Youtube.
But, the issue is that I don't understand how to make video ID changeable (b_DcQHbJIfE) so that one page can play any video which the Windows app sends.
Example:
External Windows app sends: https://www.externalvideoplayer.com/player/b_DcQHbJIfE
A website gets "b_DcQHbJIfE" and actually plays it on the embedded player
App then sends another video, like this: https://www.externalvideoplayer.com/player/c_gcOWSJISe
A website gets and plays "c_gcOWSJISe"
I know a little bit of PHP, and stumbled upon this code:
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $actual_link;
But I am not sure if that would work when the page is loading, since the Windows app probably opens a URL that does not exist.
Any help would be greatly appreciated! Thanks!
I figured this out, here's the code:
<!DOCTYPE HTML>
<HTML>
<?php
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" :
"http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url_ID = array_pop(explode('/', $actual_link));
?>
<iframe width="800" height="800" src="https://www.youtube.com/embed/<?php echo $url_ID?>" frameborder="0" gesture="media" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</html>
So now, when you load this PHP file, and if you add "/VIDEO ID" (https://www.example.com/test.php/c_gcOWSJISe)
The page will load any video that you enter into the URL. Note that this probably does not work on the localhost server, so you need actual server and domain to make this work.
Thanks!
Related
I have Work with PHP project in which one php page has so many category wise videos display and play but what I want is :-
I play first video it will start play and after that i click on second , third videos then all of the videos are playing, i want to stop previous video when i click on second and stop second video when i click on third and so on like that.
<?php
include("admin/dbconn.php");
$sqlAdmin ="SELECT * FROM `tbl_videos` where video_category='$rows[0]'";
$exeAdmin = mysqli_query($conn,$sqlAdmin);
$administration="";
while($arr=mysqli_fetch_array($exeAdmin)){
$video_link = $arr['video_link'];
$newId = explode("?v=",$video_link);
echo $administration.="<iframe src='https://www.youtube.com/embed/$newId[1]' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe>
";
}
?>
Starting the different videos within the iframe is done on the client side and not server side and thus you will not be able to control the behaviour via PHP.
You can, however, do it via Javascript.
Have a look here for example
Stop embedded youtube iframe?
I was using WordPress 3.8 and seen oembed API that in WP we can just simply put a link and it automatically embedded that video in WP. So, my question is that:
How can i use oembed feature? in PHP:
give me some practical example, so i can easily use that in my web
and i have seen this in Google
used the code stated in above link:
<?php
$manager = ProviderManager::getInstance();
$obj=$manager->provide("http://www.youtube.com/watch?v=QsROH9YfOZk","object");
$html=$obj->renderClass();
?>
I used that code locally. So,
I appreciate if you tell me that,
Can i implement this API locally means to test ??
Thanks in advance.
First, you need to pass the id of the YouTube video in a special url :
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DID_VIDEO&format=xml
Example with the video : https://www.youtube.com/watch?v=l-gQLqv9f4o
We use this url :
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3Dl-gQLqv9f4o&format=xml
The output is the XML file generated :
<oembed>
<html>
<iframe width="480" height="270" src="http://www.youtube.com/embed/l-gQLqv9f4o?feature=oembed" frameborder="0" allowfullscreen></iframe>
</html>
<author_name>SoulPancake</author_name>
<height>270</height>
<width>480</width>
<thumbnail_url>http://i.ytimg.com/vi/l-gQLqv9f4o/hqdefault.jpg</thumbnail_url>
<author_url>http://www.youtube.com/user/soulpancake</author_url>
<provider_name>YouTube</provider_name>
<type>video</type>
<thumbnail_width>480</thumbnail_width>
<provider_url>http://www.youtube.com/</provider_url>
<thumbnail_height>360</thumbnail_height>
<version>1.0</version>
<title>A Pep Talk from Kid President to You</title>
</oembed>
So, all you have to do, it's pass this XML file in function simplexml_load_file of PHP. Basically you need to read a XML file to get the iframe of the video.
<?php
$xml = simplexml_load_file("http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3Dl-gQLqv9f4o&format=xml");
echo $xml->title . "<br />";
echo $xml->html;
echo $xml->author_name;
?>
You will have the title of the video, the iframe code and the author of the video.
I use iframe to view files from onedriver on my web app php.
it works fine before, but recently I can not, I have tried many ways but no result
This is code for my file php
<iframe src="https://onedrive.live.com/view.aspx?cid=ca91cd81c0fee9e6&resid=CA91CD81C0FEE9E6%21262&app=Word&authkey=%21AJHFjDm4aQXDEb4&wdo=1" frameborder="0" width="100%" height="100%"></iframe>
I was wrong place, everyone helps me!
On the document, right click and select: "embedded".
It will generate an iframe for you.
More information
i'm using shadowbox for my website to open the big images with clicking thumbnails as you know. My Problem is, i'm fetching the users' facebook profile photo like :
$large = "https://graph.facebook.com/{$id2}/picture?type=large";
$small = "https://graph.facebook.com/{$id2}/picture?type=square";
And it's working perfect, but in shadowbox i have problem with large image..
I'm calling this in shadowbox like :
<a href="<?php echo $large; ?>" rel="shadowbox">
<img style="max-width:50px; max-height:50p;" src="<?php echo $small; ?>" />
</a>
As you can imagine, small image is showing perfect, but when i click on the small image which has href, it fails to show the large image.
I've tried to change large image variable to this :
$large = "https://graph.facebook.com/{$id2}/picture?type=large&redirect=false";
but also it has failed to show the large image..
Hope you can help, thank you
I haven't worked with Shadowbox before, so I don't know how it works behind the scenes. It may be that it can't deal with a url that returns another url for the large image.
Try making the API call with php and then passing this result to shadowbox.
$large = file_get_contents("https://graph.facebook.com/{$id2}/picture?type=large&redirect=false");
Of course, using file_get_contents() like this is a quick and dirty method. If it works, before you roll this out to a production site, you'll want to use cURL or better yet the Facebook PHP SDK to do this.
Assuming you're using shadowbox to show multiple users' photos on a page, you'll probably end up bumping into the API limits at some point. To prevent this, redo your API calls to grab multiple photos in one shot:
$large_photos = $fb->api('/picture?type=large&redirect=false&ids=' .
implode($ids_array, ','));
https://graph.facebook.com/{$id2}/picture?type=large&redirect=false basically returns you a text content the URL of the image. That's why it's not showing.
Eg.
https://graph.facebook.com/yungsenriady.budiman.3/picture?type=large&redirect=false
returns
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/157348_100001167523294_1569184886_n.jpg"
Try just use
https://graph.facebook.com/{$id2}/picture?type=large
I am really knew to the frames; i have searched this questions in the internet but i didnt find any useful tutorials.
i have a website which shows links of other websites.currently i am not using any frames in my website. my website is made using php and code used for showing links is
echo("$rows['text'] </br>");
this code is working properly(when clicked the url will open in a new window).but what i want is to make a hyperlink like this website http://www.tutorialized.com/tutorial/Dreamweaver-Tutorials-Free-Dreamweaver-Web-Design-Tutorials-and-Resource/69843 . when click to "view tutorials" it should go to a webpage with my website name and ads on top and the the other website in bottom. I know that it can be done by frames but what i dont know is how to link my hyper link to a frame (only for showing urls).
what i understood so far is that.
echo("$rows['text'] </br>");
when an user click to this hyperllink it should go to web.php which is having below code.
<frameset rows="25%,75%">
<frame src="index.php" />
<frame src=<?php echo(".$rows['url']."?> /> <-- not sure about this code,i assumed that php can be inherited -->
</frameset>
but this code is not working. can any one tell me how i can hyperlink like the website "tutorialized.com" but in a new window.
Your link should be like:
echo("<a href='http://somedomain.com/web.php' target='theNameOfTheFrame'>$rows['text']</a> </br>");
But make sure that the name for the frame is theNameOfTheFrame.