mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 10:31:20 -08:00
add Iframe test
This commit is contained in:
1 parent
4c40dbf8d8
commit
8b8d58dd66
2 files changed
+135
No files matched your search
@@ -0,0 +1,74 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Artplayer Iframe Fullscreen Web</title>
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 50px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fullscreenWeb {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 9999;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<iframe id="iframe" src="./iframe.inner.html" frameborder="0" width="100%" height="100%"></iframe>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const $iframe = document.getElementById('iframe');
|
||||||
|
window.addEventListener('message', event => {
|
||||||
|
console.log('来自子窗口的信息 -->', event.data);
|
||||||
|
|
||||||
|
const { type, data } = event.data;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'fullscreenWeb':
|
||||||
|
if (data) {
|
||||||
|
$iframe.classList.add('fullscreenWeb');
|
||||||
|
} else {
|
||||||
|
$iframe.classList.remove('fullscreenWeb');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 向子窗口发送信息
|
||||||
|
$iframe.contentWindow.postMessage({
|
||||||
|
from: 'parent',
|
||||||
|
type: 'fullscreenWeb',
|
||||||
|
data: data,
|
||||||
|
}, '*');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Artplayer Iframe Fullscreen Web</title>
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artplayer-app {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="artplayer-app"></div>
|
||||||
|
</div>
|
||||||
|
<script src="./uncompiled/artplayer/index.js"></script>
|
||||||
|
<script>
|
||||||
|
var art = new Artplayer({
|
||||||
|
container: '.artplayer-app',
|
||||||
|
url: '/assets/sample/video.mp4',
|
||||||
|
fullscreen: true,
|
||||||
|
fullscreenWeb: true,
|
||||||
|
autoOrientation: true,
|
||||||
|
whitelist: ['*'],
|
||||||
|
});
|
||||||
|
|
||||||
|
art.on('fullscreenWeb', state => {
|
||||||
|
// 向父窗口发送信息
|
||||||
|
window.parent.postMessage({
|
||||||
|
from: 'child',
|
||||||
|
type: 'fullscreenWeb',
|
||||||
|
data: state,
|
||||||
|
}, '*');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 接收父窗口的信息
|
||||||
|
window.addEventListener('message', (event) => {
|
||||||
|
console.log('来自父窗口的信息 -->', event.data);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in new issue
Block a user