46 lines
1.4 KiB
HTML
46 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>网易云音乐</title>
|
||
<style>
|
||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
html, body { width: 100%; height: 100%; overflow: hidden; background: #1a1a1a; }
|
||
#frame {
|
||
position: absolute;
|
||
top: 0; left: 0;
|
||
width: 1280px; /* 网易云 PC 版参考宽度 */
|
||
height: 720px; /* 参考高度(16:9) */
|
||
transform-origin: 0 0;
|
||
border: none;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<iframe id="frame" src="https://music.163.com/st/webplayer" allow="autoplay; encrypted-media"></iframe>
|
||
<script>
|
||
// 动态缩放:使网易云 PC 版 UI 适配 Hearth 的内容区(横屏)
|
||
// Dynamically scale the NetEase PC UI to fit Hearth's landscape content area
|
||
(function () {
|
||
var FRAME_W = 1280;
|
||
var FRAME_H = 720;
|
||
function fit() {
|
||
var frame = document.getElementById('frame');
|
||
var w = window.innerWidth;
|
||
var h = window.innerHeight;
|
||
var scale = Math.min(w / FRAME_W, h / FRAME_H);
|
||
frame.style.transform = 'scale(' + scale + ')';
|
||
// 缩放后居中
|
||
var sw = FRAME_W * scale;
|
||
var sh = FRAME_H * scale;
|
||
frame.style.left = ((w - sw) / 2) + 'px';
|
||
frame.style.top = ((h - sh) / 2) + 'px';
|
||
}
|
||
window.addEventListener('resize', fit);
|
||
fit();
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|