Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

problem with video thumbnails


Go to End


10 Posts   2920 Views

Avatar
Rishi

Community Member, 97 Posts

3 February 2010 at 5:22am

hello
first of all i would like to thank you for your great and timely help in solving my issues with ffmpeg,now video is running fine in my site but i have few problems in that
in my video.ss file when ever i am using
$Video
then it is showing the video

but i am not been able to use the other function like
$Player(200,200)
or
$VideoPopup(200,200)
or
<% control VideoThumbnail %>$CroppedImage(50,50)<% end_control %>

what i want to do is i want to show a thumbnail and it is clicked then video should run or a pop up should open with video.
i have tried the following combination of code
in videoPage.ss
<% control Videos %>
<div class="link">
<div class="description">
<h3>$Title</h3>
<p>$Description</p>
</div>
<div class="resource">

$Player(200,200)
</div>
</div>
<% end_control %>
this does not gives any error but nothing is shown on the page

<% control Videos %>
<div class="link">
<div class="description">
<h3>$Title</h3>
<p>$Description</p>
</div>
<div class="resource">

$VideoPopup(200,200)
</div>
</div>
<% end_control %>

this again shows nothing and no error
<% control Videos %>
<div class="link">
<div class="description">
<h3>$Title</h3>
<p>$Description</p>
</div>
<div class="resource">
<% control VideoThumbnail %>$CroppedImage(50,50)<% end_control %>

</div>
</div>
<% end_control %>

this also shows nothing on the page

i have also tried

<% control VideoThumbnail %>$CroppedImage(50,50)<% end_control %>

in VideoPage.ss page but the result was same

but when i have this on my VideoPage.ss page it works fine
<% control Videos %>
<div class="link">
<div class="description">
<h3>$Title</h3>
<p>$Description</p>
</div>
<div class="resource">

$Video

</div>
</div>
<% end_control %>

i have checked in assest folder it is creating thumbnail there.

thank you in advance

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 February 2010 at 5:43am

Edited: 03/02/2010 5:45am

This gets confusing because your FLV component and your containing dataobject are both called "Video"..

$Player() and $VideoPopup() are methods of the FLV class, so you need to be within the scope of your FLV object in order to use those.

When you call $Video within the scope of your Video object, SSViewer looks for a property on your Video object called Video. In this case, it finds a related object. It has to handle this somehow, because it's not like $Description or $Name, which are just text fields that are easily rendered. An object needs specific instructions on how to render itself. When SS encounters this, it looks for the forTemplate() method on the object. In the case of an FLV object, you'll see that the forTemplate() method returns $Player() with some default dimensions. Think of this as a shortcut to getting the object rendered quickly and simply.

For some more customized functions, you have to get out of the scope of your Video object and into its Video component.

<% control Video %>
$Player(320,240)
$VideoPopup(100x100,640x480)
<% control VideoThumbnail %>$CroppedImage(50,50)<% end_control %>
<% end_control %>

Avatar
Rishi

Community Member, 97 Posts

3 February 2010 at 6:08am

Edited: 03/02/2010 6:09am

I am sorry i am not that technical
i am giving you the code of all my file ,i have got this code from forum only

Video.php

<?php

class Video extends DataObject
{
static $db = array (
'Title' => 'Varchar(100)',
'Description' => 'Text'
);

static $has_one = array (
// Make sure this comes first
'VideoPage' => 'VideoPage',
/**
* This relationship could be as simple as 'Video' => 'File' provided
* FileDataObjectManager::$upgrade_video is true (defaults to true).
* However, if we know the page will only contain videos, we can simplify things by
* using a direct relationship to FLV. This will give us the benefit of not having
* to worry about the allowed_file_types setting.
*
* To make this an audio resource, set the relationship to the MP3 class, e.g.
* 'AudioFile' => 'MP3'. Audio files are also subject to automatic upgrades, however,
* based on FileDataObjectManager::$upgrade_audio. (true by default).
*
*/
'Video' => 'FLV'
);

}
?>

VideoPage.php

<?php
/**
* Before getting started, be sure to test your FFMPEG installtion by adding:
* FLV::echo_ffmpeg_test();
* to your _config.php!
*
*/

class VideoPage extends Page
{
static $has_many = array (
'Videos' => 'Video'
);

public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Videos", new FileDataObjectManager(
$this,
'Videos',
'Video',
'Video',
array('Title' => 'Title', 'Description' => 'Description'),
new FieldSet(
new TextField('Title'),
new TextareaField('Description')
)
));
return $fields;
}
}

class VideoPage_Controller extends Page_Controller
{

}

?>

VideoPage.ss

<% control Videos %>
<div class="link">
<div class="description">
<h3>$Title</h3>
<p>$Description</p>
</div>
<div class="resource">

$Video

</div>
</div>
<% end_control %>

With the above code video is running fine.
i want to show a thumbnail in the page and when someone click on it iether the video starts playing or a pop up open up with the video

i have tried with
<% control Video %>
$Player(320,240)
$VideoPopup(100x100,640x480)
<% control VideoThumbnail %>$CroppedImage(50,50)<% end_control %>
<% end_control %>

in videoPage.ss
but this does not show any video or the thumbnail

thank you

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 February 2010 at 7:49am

Send me a link and I'll take a look.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 February 2010 at 7:50am

Just want to confirm.. you tried this, and it didn't work?

<% control Videos %>
<div class="link">
<div class="description">
<h3>$Title</h3>
<p>$Description</p>
</div>
<div class="resource">
<% control Video %>
$Player
<% end_control %>

</div>
</div>
<% end_control %>

Avatar
Rishi

Community Member, 97 Posts

4 February 2010 at 6:26am

thank you UncleCheese
i know i am a dumb follower of your code but your codes are simply perfact...they work perfactly..its me who i not been able to follow your code but i am trying my best to follow you and give you less pain in implementing your coded.
thank you once again your last code works perfactly and even the video thumbnail is working now
thanks

Avatar
bunheng

Community Member, 78 Posts

18 August 2011 at 12:57pm

Good Morning From Cambodia,

I am having problem with video thumbnails and video popup player as well. I did not see any video thumbnails files within the directory video_thumbnails in asset folder. I see there are records within Files & Images -> asset -> video_thumbnails. For the VideoPopup i saw only blank black popup it looks like the video not loaded. I did check the following as well.

FLV::echo_ffmpeg_test();
FFMPEG is installed on your server and working properly. Code: 1

In ffmpeg_log i saw the the following message:
[2011-08-18 02:40:08] ffmpeg
[2011-08-18 02:40:08] 'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.

I really appreciated if you could point me the place to fix it. This is charity organisation website waiting to launch this week.

----------------------------------------------------
VideoPage.php
----------------------------------------------------
class VideoPage extends Page {

static $db = array();
static $has_one = array
(
'VideoFile' => 'FLV'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab(
"Root.Content.Video",
new FileUploadField('VideoFile'));
return $fields;
}
}
class VideoPage_Controller extends Page_Controller {

}
--------------------------------------------
VideoPage.SS
--------------------------------------------
<% control VideoFile %>
$Player(200,200)
$VideoPopup(300,200)
<% end_control %>

Thanks
Bunheng

Avatar
UncleCheese

Forum Moderator, 4102 Posts

19 August 2011 at 1:23am

That test isn't 100% reliable. It looks very much to me like you do not have FFMPEG installed.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Go to Top