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?
Related
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!
So for my Garry's Mod server, I have a loading screen using my website. I only have an image currently, but I wan't to make it play a song while the user waits while loading. My plan is that I make a list of YouTube links, and the PHP coding picks a random link, and plays that song. I have no clue on how to use PHP except for variables.
As per your question, I suggest to you one example. So, Try the code,
Youtube URL look like this : http://www.youtube.com/watch?v=yWsqTrDJ_gU
The part you're going to want to copy is everything after the equals sign, or in the example above: yWsqTrDJ_gU
Copy on that text into a text file, hit Enter and paste everything after the equals sign of the URL on the next video page on the following line. You'll end up with a series of lines that look something like this:
5MQ0QX870FE
yWsqTrDJ_gU
JyTawuNvQi0
HwRQ9dbti-4
_ziv_WeBLvo
Save this text file with a meaningful name and upload it to your Web server. Next you need to build the code to display your video. If you copy the following and paste it onto a page that supports PHP, replacing only the YourVideoList.txt with the path to your file, you should get a YouTube player with a randomized set of videos.
<?php
// Build an array from the list of YouTube videos
// Replace YourVideoList.txt with the path to your text file
// This will likely be something like /home/accountname/public_html/foldername/etc
$video_array = file('YourVideoList.txt');
// Randomly pick one video from the array
$video = $video_array[rand(0, count($video_array) - 1)];
$video = trim($video);
?>
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/<?php echo $video;? >"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/<?php echo $video;?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>
Note: Don't copy anything beyond this point for your code.
Hope! it's work for you!!
I have a web site I'm working on and for some reason some of my videos don't display. The first videos display but the next one's don't.
So first one looks like this:
And the rest look like this:
I know the url's I am using are correct, I dump them to the screen and navigated to them to make sure they weren't broken. This is in chrome, same thing happens in IE.
This is the code I am using to embed:
<iframe width="420" height="315" alt="Jesus Culture" src="<?=$row?>"
frameborder="5" allowfullscreen></iframe>
I'm using similar code to yours for multiple videos on one page,
i.e.
<iframe width="425" height="349" src="http://www.youtube.com/embed/video-code" frameborder="0" allowfullscreen=""></iframe>
Make sure that your urls have the embed format. Also try to place the src value hardcoded (no php) to check whether in that case displaying multiple videos on the page will be an issue.
This is kind of stupid question but is there any way to play videos just by using two pages, I mean like instead of creating an html page for every video I upload to my website, can I have only two php pages and then pass the video from the first page and play on the second one?
I know about passing variables in url but I am kinda confused on how to do this.
I actually embedded my videos from google drive and have a format like
<iframe src="https://docs.google.com/file/d/0B5ZMsnZoUVNSWHhxeGc/preview" width="640" height="385"></iframe>
would it be possible to do like
<a href="play.php?video='test.mp4'>Click to play</a>
or like
$video= 'test.mp4';
<a href="play.php?vid='$video'>Click to play</a>
play.php
$video = $_GET['vid']
if(!empty(($video)){
//then play the video here.
}
I'm expecting you're usnig HTML5.
Let's say there's a list of videos on the first page, and you click on a name of video and it redirects you to second page. Pass the video url (or any identifier for server to know which video) in the link. You can do it like
Cats!!
This will send vid_url as a GET variable on second page. page2.php is, as you can imagine, very simple
<?php
$vid = $_GET['vid'];
//echo $vid;
echo "<video width='320' height='240' controls>
<source src=".$vid." type='video/mp4'>
Your browser does not support the video tag.
</video>"
?>
Of course, you'll do something more elaborate than simply using "echo" for formatted HTML output.
Yes. Instead of empty use isset:
if (isset($_GET["vid"])){
$video = $_GET['vid'];
//play video
}
Play This Video
And On Play.php page add this code
if(isset($_GET['video'])&&!empty($_GET['video']))
{
$Video = $_GET['video'];
// Use the Source of your video anyway you like to play the video
}else
{
echo 'No video selected to play';
}
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