Skip to content

Commit 1175df0

Browse files
committed
feat: video requestPictureInPicture pratice
1 parent f92f561 commit 1175df0

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
<div class="justify">
6666
文字两端对齐文字两端对齐文字两端对齐文字两端对齐文字两端对齐
6767
</div>
68-
68+
<video controls muted="muted">
69+
<source
70+
src="http://aliyun36001.baomihua.com/05a0198bd7508ba99d9f54a6cb2c6945/5ced504f/3958/39574859_7_9a8aece27abb14c4d6f431752b2e8045.mp4"
71+
type="video/mp4">
72+
</video>
6973
</body>
7074

7175
</html>

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { bindPloyfill } from '../bind_applay_call/bind.js'
88
/* memory monitor */
99
import monitor from '../memoryMonitor/index'
1010

11-
11+
import { reqVideoPictureInPicture } from '../video/index.js'
1212

1313

1414

video/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
export function reqVideoPictureInPicture() {
3+
let video = document.getElementsByTagName('video')[0];
4+
video.style.width = '1000px';
5+
video.style.height = '1000px';
6+
video.width = 1000;
7+
video.height = 1000;
8+
video.addEventListener('canplaythrough', function (event) {
9+
const promise = video.play();
10+
promise.then(() => {
11+
video.removeAttribute('muted')
12+
console.log(video.volume)
13+
})
14+
document.addEventListener('click', function () {
15+
video.requestPictureInPicture();
16+
video.volume = 1;
17+
})
18+
})
19+
}
20+
21+
reqVideoPictureInPicture();

0 commit comments

Comments
 (0)