简体   繁体   English

HTML & Js 使视频 url 在默认设备视频播放器应用程序中打开

[英]HTML & Js make video url open in default device video player app

I'm creating a mediaplayer website where I can play my uploaded videos.我正在创建一个媒体播放器网站,我可以在其中播放我上传的视频。 I'd like to add a button where an user can click and the devices asks with which app play the video.我想添加一个用户可以点击的按钮,设备会询问使用哪个应用播放视频。

I tried something like that:我试过这样的事情:

 window.open("video.mkv", '_blank');

But the browser on my android device just download the video without reading the file as a playable video with an external player.但是我的 android 设备上的浏览器只是下载视频,而不用外部播放器将文件作为可播放的视频读取。

Is this something related to the browser or I can give a hint to the browser on how to open the file?这是否与浏览器有关,或者我可以提示浏览器如何打开文件?

I think that if the click on the link directly downloads the file is because the device hasn't any app that has explicitly told the system that it can manage that kind of content.我认为,如果点击链接直接下载文件,是因为设备没有任何应用程序明确告诉系统它可以管理那种内容。

Or if you use a regular link <a>...</a> instead of a window.open you can add some mime/type information to the link, it maybe helps...或者,如果您使用常规链接<a>...</a>而不是window.open您可以向链接添加一些 mime/type 信息,这可能会有所帮助...

Or keep the window.open and add some extra information as defined here: https://developer.mozilla.org/en-US/docs/Web/API/Window/open或者保持window.open并添加一些在此处定义的额外信息: https : //developer.mozilla.org/en-US/docs/Web/API/Window/open

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM