视频无法在Codeigniter中使用html5媒体播放器

时间:2015-06-15 09:48:13

标签: php html5 codeigniter video web-applications

我尝试在使用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。

3 个答案:

答案 0 :(得分:0)

您需要将视频放在application文件夹之外。

在MVC架构中,除models外,用户不应直接访问viewscontroller

在项目根目录中创建一个名为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;
}

答案 1 :(得分:0)

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;
}

将所有视频放在应用程序文件夹之外。然后回电话。

所以你的文件夹Structurer会像

一样改变
  1. 应用
  2. 资产
    • 视频
    • CSS
    • JS​​
    • 图像
  3. 系统
  4. 的index.php
  5. .htacess
  6. 额外注意事项:

    在config.php中

    $config['base_url'] = '';
    $config['index_page'] = '';
    

答案 2 :(得分:0)

我要为我工作的是在项目根目录中创建一个资产/视频/目录。

<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/"。如果我引用完整路径,则无法使用。