我正在尝试使用codeigniter框架创建的Web应用程序中使用html5媒体播放器播放视频。这是我到目前为止所拥有的:
public function view($settings, Screen $screen)
{
$view = "<video width='100%'' height='100%'' controls>
<source src='application/views/video/Arrow.mp4' type='video/mp4'>
Your browser does not support the video tag.
</video>";
return $view;
}
}
我尝试将视频文件放在不同的目录中,我尝试为文件类型添加 mime。
您需要
将视频放在文件夹之外application
。
在 MVC 体系结构中,用户不应直接访问models
和views
,但 controller
除外。
在项目根目录中创建一个名为 videos
的文件夹,将Arrow.mp4
文件放入该文件夹中,然后更改此代码块以获取结果。
function view ( $settings, $screen )
{
$view = "<video width='100%' height='100%' controls>
<source src='videos/Arrow.mp4' type='video/mp4'>
Your browser does not support the video tag.
</video>";
echo $view;
}
function view ($settings, $screen )
{
$url = base_url()
$view = "<video width='100%' height='100%' controls>
<source src=".$url."'assets/video/Arrow.mp4' type='video/mp4'>
Your browser does not support the video tag.</video>";
return $view;
}
将所有视频放在应用程序文件夹之外。 并回拨。
所以你的文件夹结构器会像
- 应用
- 资产
- 视频
- .css
- .JS
- 图像
- 系统
- 索引.php
- .htacess
额外说明 :
在配置中.php
$config['base_url'] = '';
$config['index_page'] = '';
我的工作是在项目根目录中创建一个资产/视频/目录。
<video controls loop>
<source src="assets/video/videofile.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
专门将资产文件夹引用为"资产",而不是引用为C:/xampp/htdocs/projectfolder/assets/video/"
。如果我引用完整路径,它不起作用。