JohnOP Posted March 10, 2011 Share Posted March 10, 2011 Ok say i have a database with users who have a video url field for them to enter a video url to be submitted to the database, im trying to create a page where the videos will be displayed one at a time for example ' 1st video plays then it switches to the next random video from the database and so on' i want only to play so many seconds of the video before it switches as they will be presentations so i dont want viewers to watch them all in full, could anyone help me out with some code or feedback on this please? Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/ Share on other sites More sharing options...
JohnOP Posted March 10, 2011 Author Share Posted March 10, 2011 OK i have made a popup for where the video will be displayed, i can grab all the urls from the database for all users but i dont know how to display only of those videos for so many seconds then the popup refreshes to a new video for so many second, please could anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185645 Share on other sites More sharing options...
HuggieBear Posted March 10, 2011 Share Posted March 10, 2011 You could use header() to refresh the current page with a random video from the database: <?php header('refresh: 5; url=this_page.php' ); /* Refresh browser */ ?> Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185648 Share on other sites More sharing options...
JohnOP Posted March 10, 2011 Author Share Posted March 10, 2011 Yeah i know how to refresh the page but how can i have it where after that refresh a new video is shown from the database, instead of the one we previously seen before the refresh? When it refreshes it will still be the same link so i cant redirect them every refresh. Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185652 Share on other sites More sharing options...
HuggieBear Posted March 10, 2011 Share Posted March 10, 2011 Change your database query to select just a single random video. SELECT video_url FROM user_videos ORDER BY RAND() LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185658 Share on other sites More sharing options...
JohnOP Posted March 10, 2011 Author Share Posted March 10, 2011 Ahh i see i never thought of that at all, just to get this cleared up is it possible to have a variable in this <object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/<?php echo $vid; ?>"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/<?php echo $vid; ?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object> I have tried this a few ways as a test and the video does not show. <?php $vid = "uBBly_0E7f0&feature=feedu"; ?> <object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/<?php echo $vid; ?>"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/<?php echo $vid; ?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object> Though i even tried it without a variable and you as the whole link and still the video doesn't show hmm. Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185662 Share on other sites More sharing options...
jasonrichardsmith Posted March 10, 2011 Share Posted March 10, 2011 Well what does your source show when the page renders. Does straight html work? I also don't think you need the &feature=feedu Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185684 Share on other sites More sharing options...
JohnOP Posted March 10, 2011 Author Share Posted March 10, 2011 Ok i got this to work <embed src=" http://www.youtube.com/v/mnPCMIUvT0g&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"> But this doesn't <embed src=" http://www.youtube.com/v/<?php echo $videoid; ?>&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"> with or without autoplay=1 at the end, any ideas why not? Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185689 Share on other sites More sharing options...
jasonrichardsmith Posted March 10, 2011 Share Posted March 10, 2011 What html is it producing? Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185699 Share on other sites More sharing options...
JohnOP Posted March 10, 2011 Author Share Posted March 10, 2011 The page stays blank. Source code 53i8UpqT80U<embed src=" http://www.youtube.com/v/&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"> Not showing the php at all My code <?php echo "53i8UpqT80U"; ?> <embed src=" http://www.youtube.com/v/<?php echo $videoid; ?>&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"> Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185705 Share on other sites More sharing options...
JohnOP Posted March 10, 2011 Author Share Posted March 10, 2011 I got it thanks for the help everyone. Quote Link to comment https://forums.phpfreaks.com/topic/230215-play-random-youtube-videos-from-urls-in-database/#findComment-1185752 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.