2 #include <boost/filesystem/operations.hpp>
5 #include <Wt/WFlashObject>
6 #include <Wt/WMediaPlayer>
18 : WContainerWidget(parent)
20 addStyleClass(
"WsVideo");
29 WContainerWidget::load();
33 if ( !rootNode )
return;
34 NodePtr curNode = rootNode.get()->eatPath(wApp->internalPath());
35 if ( !curNode )
return;
37 std::string videoFile = m_sDocumentRoot + wApp->internalPath();
38 WText* pText =
new WText(curNode.get()->getDisplayName(
true));
39 pText->addStyleClass(
"WsTitle");
41 std::string extension = boost::filesystem::path(videoFile).extension().string();
42 if ( extension ==
".ogv" || extension ==
"mp4" ) {
43 boost::algorithm::replace_first(videoFile,
WsApp->docRoot(),
"");
44 WVideo* video =
new Wt::WVideo(
this);
45 video->addSource(Wt::WLink(videoFile));
47 video->resize(640, 360);
50 if ( extension ==
".m4v" ) {
51 boost::algorithm::replace_first(videoFile,
WsApp->docRoot(),
"");
52 WMediaPlayer* player =
new WMediaPlayer(Wt::WMediaPlayer::Video,
this);
53 player->addSource(Wt::WMediaPlayer::M4V, Wt::WLink(videoFile));
55 player->setVideoSize(640, 360);
58 if ( extension ==
".youtube" ) {
60 if ( boost::filesystem::exists(videoFile) ) {
61 std::ifstream f(videoFile.c_str());
62 std::getline(f, sUrl);
64 if ( sUrl.size() < 1 )
return;
66 WFlashObject* flash =
new WFlashObject(sUrl,
this);
67 flash->setFlashParameter(
"allowFullScreen",
"true");
68 flash->resize(640, 360);
boost::shared_ptr< WsAbstractNode > NodePtr
Interface that provides differents methods for accessing the FsTree as well as other features...
WsVideo(Wt::WContainerWidget *parent=0)
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
#define WsApp
Define a shortcut to the application instance.
NodePtr getAccessRoot()
return the root node of the access tree starting from the root