简体   繁体   English

从Android上的html链接加载mp4视频

[英]Loading an mp4 video from an html link on Android

I have a html file on my Samsung android tablet that has a link like this: 我的Samsung平板电脑上有一个html文件,其中包含以下链接:

<a href="./video/0001_a1.mp4" target="_blank">Click to play local 0001_a1.mp4</a>

When I click it I wanted it to open the video file that is in the sub directory /video beneath but only the link background changes like the link is being pressed but no video plays. 当我点击它时,我希望它打开位于子目录/视频下方的视频文件,但只有链接背景发生变化,如链接被按下但没有视频播放。 If I remove the video file and press the link I get an error that it can't find the file. 如果我删除视频文件并按下链接,我会收到一个无法找到该文件的错误。 So I know that something is trying to happen. 所以我知道有些事情正在发生。 I have also tried 我也试过了

<a href="video/0001_a1.mp4" target="_blank">Click to play local 0001_a1.mp4</a>

With the same results. 结果相同。 Both work fine when on a Windows PC. 在Windows PC上都可以正常工作。

How can I load local videos using an html link on Android? 如何使用Android上的html链接加载本地视频?

In mobile browsers you must call window.open inside onClick instead of set href attribute: 在移动浏览器中,您必须在onClick内调用window.open而不是set href属性:

<a href="#" onclick="window.open('./video/0001_a1.mp4','_blank')">
    Click to play local 0001_a1.mp4
</a>

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

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