vedio标签全屏播放
时间: 2023-08-25 21:19:01 浏览: 119
Android编程实现WebView全屏播放的方法(附源码)
要使video标签全屏播放,可以使用以下方法:
在video标签中添加属性:webkit-playsinline="true",x-webkit-airplay="true",playsInline={true},x5-playsinline="true",x5-video-orientation="portraint"。此外,还可以添加样式object-fit: fill来确保视频铺满整个div容器。例如:
```html
<video controls style="width: 100%; height: 100%; object-fit: fill" autoplay>
<source src="video.mp4" type="video/mp4">
</video>
```
使用JavaScript控制播放可以使用以下代码:
```javascript
var myVideo = document.getElementById("video1");
try {
myVideo.play();
} catch (error) {
console.log("video被阻止了, 需要手动触发按钮或别的事件,和用户有交互后,再调用play()");
}
```
通过以上方法,你可以在video标签中添加必要的属性和样式,实现视频全屏播放的效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [h5使用video标签解决自动全屏问题](https://blog.csdn.net/qq_24978681/article/details/117230378)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [HTML中 video标签样式铺满全屏](https://blog.csdn.net/wsdshdhdhd/article/details/125928150)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文