SimplePortal
Development => Feature Requests => Topic started by: Old Fossil on April 07, 2010, 11:51:53 AM
-
OK so we have the random photos in the gallery blocks.
What about random video clips?
Not so much a request as a brainwave.
Probably me being ambitious.
-
Doesn't sound too hard.
Here is a youtube video clip example:
$videos = array(
'id1',
'id2',
'id3',
'id4',
// Add more ids there list this:
// 'id',
);
$video = $videos[rand(0, count($videos) - 1)];
echo '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/', $video, '&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/', $video, '&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>';
You will need to extract the youtube id yourself, usually its something like 'h5isi4kjf' which is within the url.
When watching a video at youtube the format of the url is: "http://www.youtube.com/watch?v={id}" (Hopefully that should help).
-
Thanks bud.
Thought I was being too ambitious then.
Surprised no one else has thought of it.
-
Well, its easy because youtube provide their own embed code, if it was a matter of trying to show videos from a whole bunch of sources it would be more annoying. ;)
-
Would i get away with having two embeds in one block as they come?
-
Something like this?
$videos = array(
'id1',
'id2',
'id3',
'id4',
// Add more ids there list this:
// 'id',
);
$video = $videos[rand(0, count($videos) - 1)];
echo '
<div style="float: left;">
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/', $video, '&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/', $video, '&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
</div>';
$video2 = $video;
while ($video2 == $video)
$video2 = $videos[rand(0, count($videos) - 1)];
echo '
<div style="float: left;">
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/', $video2, '&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/', $video2, '&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
</div>';
That code will show two unique videos horizontally next to each other, if you want them to be shown vertically that will be easy to change.
-
Oops sorry bud.
I meant one then a different one after a page refresh.
-
That should happen if you have enough video ids. Although sometimes the php rand function will return the same value for your two page views, its just unlucky if you happen to load the same video twice in a row, stopping it from happening would take more effort. ;)
-
Will give it a go.
The new forum is going to be given a makeover soon.
www.mkaware.co.uk if ya wanna have a nosy peek.
-
Sorry bud but I tried it on the test forum with no luck.
-
Since you are using Aeva Media, why not use the Aeva Media SSI?
Here's a block I use for random images from a single album.
I have not tested it for videos.
You may want to change the div CSS class for videos.
Suppose you've put the vids in album 19
global $sourcedir;
include_once($sourcedir . '/Subs-RHSC.php');
rhsc_album(19,,1);
<?php
if (!defined('SMF'))
die('Hacking Attempt...');
function rhsc_album ($album=0, $order='random', $start=0, $count=5)
{
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
if ( is_int($album) && !($album==0) )
{
$aeva_albums = array($album);
$aeva_all_albums = true;
}
else
{
$aeva_all_albums=TRUE;
$aeva_albums = array();
}
if ( $order === 'random' )
$aeva_order = 'RAND()';
else
$aeva_order = 'DESC';
echo preg_replace('~<div class="highslide-maincontent">.*?</div>.*?</div>~', '',
aeva_listItems(aeva_getMediaItems($start, $count, $aeva_order, $aeva_all_albums, $aeva_albums ), false, '', 5)
)
;
return false;
}
?>
-
Hiya
Would ya mind if I have a nosy at the one on ya forum?
Have a look at www.mkaware.co.uk
The forum will be having a major refit soon.
We have strted a major poster campaign asking local libraries and shops if they are willing to display one.
-
You are welcome to view
http://rockhallsailingclub.org (http://rockhallsailingclub.org)
You can see pretty much everything as a guest.
-
Didn't realise ordinary documents could be added to the media.
I have only recently started adding video clips.
:-[
-
It's a sort-of CMS-like way to organize documents.
Much better than losing them in attachments.
Did the random-video-album-item thing work out?
-
Yah it works great, but maybe you didn't want youtube videos to be displayed randomly how about online games?
-
Then you would start with a block for online games.
Figure out how games are displayed in a block.
Figure out how to create an array that is a list of the games, then (here's the easy part) choose one randomly from the array.
Then, display the chosen game as usual.
You could start a new topic for this in customizations.