HTML5 video play() not playing ionic 3 quot;ios and android(HTML5 视频播放()不播放 ionic 3“ios 和 android)
问题描述
我已经搜索了很长时间并尝试了很多方法,但似乎没有任何效果.我有一个视频标签,当我点击它时我想播放它.我正在研究 Ionic 3 和 Angular.代码如下所示.如果我错过了什么,请帮助我或指导我.
I have been searching for a long time and have tried a lot of approaches but nothing seems to be working. I have a video tag which I want to be played when I tap over it. I am working on Ionic 3 and angular. The code is shown below. Please help me out or direct me if I missed anything.
HTML:
<video id="edit-video-element"
width="100%"
[src]="videoPath"
webkit-playsinline
poster="{{thumbnailPath}}" controls autobuffer >
</video>
.ts 文件
this.video = document.getElementsByTagName('video')[0];
onVideoClick(e) {
(this.video.paused) ? this.video.play() : this.video.pause();
}
它没有显示任何问题,但根本不起作用.
Its not displaying any issues, but not working at all.
更新:
<video *ngIf="hasVideo" width="100%" controls autoplay>
<source [src]="videoPath" type="video/mp4">
</video>
我添加了这个,然后在 .ts 文件中我的 videoPath 为:
I added this and then in the .ts file I have the videoPath as:
file:///private/var/mobile/Containers/Data/Application/99091302-995E-40C7-AF66-0E07BCF09220/tmp/trim.E4AE7B29-06BB-4077-A56A-B546A53267DC.MOV
file:///private/var/mobile/Containers/Data/Application/99091302-995E-40C7-AF66-0E07BCF09220/tmp/trim.E4AE7B29-06BB-4077-A56A-B546A53267DC.MOV
更新:我能够使它适用于相册中的文件我必须安装DomSanitizer",然后在我的视频标签中添加 _DomSanitizationService.bypassSecurityTrustUrl(yourFilePath).
Update: I was able to make it work for the files from photo album I had to install "DomSanitizer" and then add _DomSanitizationService.bypassSecurityTrustUrl(yourFilePath) in my video tag.
推荐答案
试试这个.对我来说效果很好.
Try this out. It's working fine for me.
HTML
<video #videoPlayer class="video-player" controls></video>
TS
@ViewChild('videoPlayer') mVideoPlayer: any;
ionViewDidLoad() {
let video = this.mVideoPlayer.nativeElement;
video.src = "aHR0cDovL3RlY2hzbGlkZXMuY29tL2RlbW9zL3NhbXBsZS12aWRlb3Mvc21hbGwubXA0";
video.play();
}
sass
.video-player {
width: 100%;
height: 100%;
}
这篇关于HTML5 视频播放()不播放 ionic 3“ios 和 android"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:HTML5 视频播放()不播放 ionic 3“ios 和 android"


- addEventListener 在 IE 11 中不起作用 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07