我无法查看存储文件夹中的视频文件。我的萤火虫显示确定的响应并显示一些通知消息。我认为问题来自
<source src="'+response.profileVideo+'" type="video/webm">.
请你查一下并帮我加载视频。
JS
$( "#view-from-server" ).click(function(e){
e.preventDefault();
$.get("/profile/video", function(response){
$( "#profile-video" ).html('<video width="400" height="240" controls id="profile-video"><source src="'+response.profileVideo+'" type="video/webm"></video>');
});
控制器页面
public function index()
{
$id = Auth::user()->id;
$details = User::select('id', 'created_at')->find($id);
$encrypt = md5($details->id.$details->created_at);
$directories = Storage::files($encrypt); // Listout Files
$webm = preg_grep('/\/.*.webm$/', $directories);
foreach($webm as $files){
$split_folder_file = explode('/', $files); //60e4dda43c442fe610bdbd4a0e5c3a12/4135209867745277.webm
$splitted_file = end($split_folder_file); //4135209867745277.webm
/*$file = Storage::disk('local')->get($encrypt.'/'.$splitted_file);
return response($file, 200)
->header('Content-Type', 'video/webm');*/
$userdata = 'userdata';
$filenameresult = storage_path().'/'.$userdata.'/'.$encrypt.'/'.$splitted_file;
return response()->json(['profileVideo' => $filenameresult]);
}
}
HTML
<div class="text-center">
<button type="button" class="btn btn-sm btn-rounded btn-default" id="view-from-server">View Profile Video</button>
<br>
<div id="profile-video"></div>
</div>
Firebug回复
"C:\xampp\htdocs\ct\storage/userdata/60e4dda43c442fe610bdbd4a0e5c3a12/8759253552413012.webm"
Firebug通知
All candidate resources failed to load. Media load paused.
用萤火虫检查
当我用firebug检查html时,结果如下所示。
<div id="profile-video">
<video width="400" height="240" controls="" id="profile-video">
<source src="C:\xampp\htdocs\ct\storage/userdata/60e4dda43c442fe610bdbd4a0e5c3a12/9462835104782046.webm" type="video/webm"/>
</video>
</div>
htaccess的
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
答案 0 :(得分:0)
问题似乎是当您请求webm文件时,它没有发送适当的MIME类型,因此Firefox会抛出错误,即没有支持格式/ MIME类型的文件。
由于您使用的是apache,因此您有两个选择:
if(serviceContext.checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
//Read Phone state
}else{
}
或者,使用# /etc/apache2/mime.types
# add the following two lines to the file
audio/webm weba
video/webm webm
.htaccess