21307 Posts in 5737 Topics by 2603 members
| Go to End | Next > | |
| Author | Topic: | 1445 Views |
-
display all the video in a uploaded folder in a page

11 January 2010 at 5:49am Last edited: 11 January 2010 5:50am
hello
i need to show all the video present in a uploaded folder in my home page,Please lete me know how to do that.Video can be in mp4 or avi format
thank you in advance -
Re: display all the video in a uploaded folder in a page

14 January 2010 at 7:13pm
I would say either use the YouTube Module (and modify it) and host the files on YouTube or look at the Gallery Module as it pulls images from a specified directory and will show you the setup for adding the correct db and cms fields to your HomePage type. Hope this make sense
-
Re: display all the video in a uploaded folder in a page

14 January 2010 at 9:09pm
thanks for your reply
Yes you are correct it does make sense but the problem is when i try to read all the video the video is not getting played as we need specific code to play a video and also we need to change the video format into flv so tht it can be viewed in pages -
Re: display all the video in a uploaded folder in a page

15 January 2010 at 11:29am Last edited: 15 January 2010 11:29am
I believe flash version 9 can use an external .mp4 file this is the standard for vodcasting I have used Jquery Flash Plugin to generate the embed tags and load a flash player I wrote in actionscript basically just loads/plays the movie via flashvars
$(function(){
$('#vodcast').flash(
{
src: 'website/flash/vodcast_player.swf',
width: 240,
height: 205,
flashvars: { src: 'somefile.mp4' },
wmode: 'transparent'
},
{ version: 9 }
);
});You can see an example here the whole vodcasts are controlled in the backend by silverstripe so this is possible!
-
Re: display all the video in a uploaded folder in a page

15 January 2010 at 11:49pm
your site looks great ,
Can you please let me know how to achieve the same in my page,Please let me know in which file i need to write the code and where and how to call it in template,thank you in advance
-
Re: display all the video in a uploaded folder in a page

18 January 2010 at 1:32pm Last edited: 18 January 2010 1:42pm
1) Create a flash file that will load and external .mp4 file via flashvars using flash 9.0 AS3 Netstream
2) Download jquery.flash.js
4) Create your video page type and a holder page type
VodcastPage.php
class VodcastPage extends Page
{
static $db = array(
'Episode' => 'Text',
'Date' => 'Date',
'Summary' => 'HTMLText',
'RunningTime' => 'Time'
/*'Archive' => 'Boolean'*/
);
static $has_one = array('MP4'=>'File');
function getCMSFields()
{
$fields = parent::getCMSFields();
// remove default fields.
$fields->removeFieldFromTab('Root.Content.Main', 'Title');
$fields->removeFieldFromTab('Root.Content.Main', 'MenuTitle');
$fields->removeFieldFromTab('Root.Content.Main', 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Episode'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Title', 'Title'));
$fields->addFieldToTab('Root.Content.Main', new TextField('MenuTitle', 'Menu Title'));
$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date', 'Date'));
$fields->addFieldToTab('Root.Content.Main', new TextField('RunningTime', 'Running Time (HH:MM:SS)'));
$fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('Summary', 'Summary'));
// file upload
$vodfile = new FileIFrameField('MP4', 'Upload MP4 File (.m4v)', NULL, NULL, NULL, 'vodcasts');$fields->addFieldToTab("Root.Content.Main", $vodfile);
return $fields;
}
function Mp4File()
{
$file = DataObject::get('File', "`ID` = '{$this->MP4ID}'");
if($file) {
return $file->First();
}
}
function Mp4Download()
{
$file = self::Mp4File();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Last-Modified: ".date("D, d M Y H:i:s")." GMT");
header("Content-type: video/m4v");
header("Content-Disposition: attachment; filename=".basename(str_replace(' ', '_', $file->getFilename())));
header("Content-Transfer-Encoding: binary");
readfile($file->getFullPath());
}
function getFilename()
{
$file = self::Mp4File();
return $file->Filename;
}
function getFileURL()
{
return self::BaseHref().self::getFilename();
}
function getFilesize()
{
$file = self::Mp4File();
if($file) {
return $file->getSize();
}
}
function getFilesizeBytes()
{
$file = self::Mp4File();
if($file) {
return $file->getAbsoluteSize();
}
}
}class VodcastPage_Controller extends Page_Controller {
function init()
{
parent::init();
}
function download()
{
VodcastPage::Mp4Download();
}
}
?>VodcastHolder.php
class VodcastHolder extends Page
{static $db = array();
static $has_one = array();
static $allowed_children = array('VodcastPage');
static $default_child = "VodcastPage";
}class VodcastHolder_Controller extends Page_Controller {
function init()
{
parent::init();
Requirements::JavaScript('website/javascript/jquery.flash.js');
// important the src varibale will need to be modified and retrieve the lastest Vodcasts file path you will have top work this out as I had this in the template this was before silverstripe put all scripts at the bottom of page
Requirements::customScript(<<<JS$(function(){
$('#vodcast-playnow').flash(
{
src: 'website/flash/vodcast_player.swf',
width: 240,
height: 205,
flashvars: { src: 'somefile.mp4' },
wmode: 'transparent'
},
{ version: 9 }
);
});
JS
);}
function iTunesLink()
{
return str_replace('http://', 'itpc://', self::AbsoluteLink()) . "rss";
}
function LatestVodcast()
{
$page = DataObject::get_one("VodcastHolder");
$vodcast = DataObject::get("VodcastPage", "`SiteTree`.ParentID = $page->ID", "Date DESC", NULL, 1);
if($vodcast) {
return $vodcast->First();
}
}
function LatestMp4()
{
$vodcast = self::LatestVodcast();
$file = DataObject::get("File", sprintf("File.ID = %d", $vodcast->MP4ID));
if($file) {
return $file->First();
}
}
function LatestMp4Filename()
{
$file = self::LatestMp4();
if($file) {
return $file->Filename;
}
}
function LatestMp4Filesize()
{
$file = self::LatestMp4();
if($file) {
return $file->getSize();
}
}
}5) Create template for VodcastHolder
<% if LatestVodcast %>
<div id="latestvodcast">
<div class="inner">
<% control LatestVodcast %>
<h3>$Episode $Title.XML</h3>
<p class="date">$Date.Day, $Date.Long</p>
$Summary
</div>
<div id="vodcast-playnow"></div>
<div id="vodcast-info">
<span class="running-time">Running Time: $RunningTime</span>
<span class="filesize">Size: $Top.LatestMp4Filesize</span>
<span class="link"><a href="$URLSegment/download">Download full size video</a></span>
</div>
</div>
<% end_control %>
<% end_if %>Sorry I can't explain in more detail but gives you the general idea on how I did it, hope this helps some.
-
Re: display all the video in a uploaded folder in a page

19 January 2010 at 9:50am
thanks you CodeGuerrilla
you really saved me a lot of time and you code helped me a lot,thank you once again -
Re: display all the video in a uploaded folder in a page

19 January 2010 at 11:43am
No problem glad to help
| 1445 Views | ||
| Go to Top | Next > |



