Commit 3c147b3b authored by 15011343103's avatar 15011343103

feat

parent 2cde63cf
我有一个JSON数据,字段解释如下:
```
{
"audio_points": {
"说明": "音频相关的信息",
"字段": {
"audio_url": "音频文件的URL地址",
"points": {
"说明": "音频断点信息数组",
"包含字段": {
"start": "该段音频的开始时间(秒)",
"end": "该段音频的结束时间(秒)",
"text": "该段音频对应的英文文本",
"words": {
"说明": "单词级别的时间轴信息",
"包含字段": {
"start": "单词开始时间",
"end": "单词结束时间",
"word": "具体单词"
}
}
}
}
}
},
"pages": {
"说明": "书籍页面信息数组",
"字段": {
"image_url": "页面图片的URL地址",
"page": "页码",
"start": "该页面内容在音频中的开始时间",
"end": "该页面内容在音频中的结束时间",
"groups": {
"说明": "页面中的文本组信息",
"包含字段": {
"sentence": "识别出的英文句子",
"sentence_cn": "对应的中文翻译",
"start": "句子在音频中的开始时间",
"end": "句子在音频中的结束时间",
"reason": "时间戳缺失或特殊情况的解释说明",
"group": {
"说明": "文本在图片中的位置信息",
"包含字段": {
"rect": {
"x": "文本框左上角的X坐标(相对值)",
"y": "文本框左上角的Y坐标(相对值)",
"width": "文本框的宽度(相对值)",
"height": "文本框的高度(相对值)"
},
"text": "实际文本内容"
}
}
}
}
}
}
}
```
# 需求
我希望你基于 ./play/index.html ./play/index.css ./play/index.js 帮我实现上面数据的播放功能,主要包含如下:
1、分页展示图片,每一页放一张图片。图片按照页面尺寸适配,如果是长图则左右留白,如果是宽图则上下留白
2、页面的左下角浮动两个按钮,一个是上一页,一个是下一页。
3、播放音频,有播放和暂停的按钮,也浮动在左下角,不用显示音频元素以及音频的进度条等。
4、当音频播放到哪一页,图片分页就翻到对应页。
5、翻页动画做成左右滑动然后渐入渐出。
6、手动点击上一页/下一页如果音频正在播放则立即跳转到对应页的开始时间进行播放,如果音频是暂停或者未播放的状态,这个时候点击播放则也是在这一页的开始时间进行播放,如果音频正好暂停在这一页的某个时间,此时点击播放就是继续播放,不用跳回到本页的开始时间。
7、页面的正下方居中浮动音频对应的字幕(audio_points.points.text),音频播放到哪一句就显示哪一句,播放完就隐藏,字幕的样式用 0.2透明度的黑色背景,然后字体用白色。
8、在图片上画蓝色的矩形框,数据在pages.groups[].group.rect里,是相对于图片宽高的归一化坐标,当音频读到某个矩形框的时候就显示,过了就消失。
9、当音频播放到最后结束,跳回到第一页,音频也从零开始。
# 技术框架描述
Vue2、element-ui 2.12、jQuery 1.12.3
都是通过CDN的方式引入好的,你就不要用组件的形式新建其他文件了,都在 ./play/index.js 通过new VUE()的方式 全部实现逻辑部分就好。
我还给你提供了一个真实的数据文件 /form/defaultData.json
记得必须要用 Vue2 来实现
html, body {
height: 100%;
margin: 0;
padding: 0;
background: #fff;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
overflow: hidden;
}
body { body {
min-height: 100vh;
min-width: 100vw;
box-sizing: border-box;
}
#app {
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
}
.page-container {
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
}
.full-image-wrapper {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #fff; background: #fff;
position: absolute;
top: 0;
left: 0;
}
.full-image {
max-width: 100vw;
max-height: 100vh;
width: auto;
height: auto;
display: block;
margin: auto;
object-fit: contain;
background: #fff;
border-radius: 0;
box-shadow: none;
}
.rect-layer {
position: absolute;
border: 3px solid #2196f3;
box-sizing: border-box;
pointer-events: none;
border-radius: 4px;
z-index: 2;
background: rgba(33,150,243,0.15);
opacity: 0;
transform: scale(0.95);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.rect-layer.rect-visible {
opacity: 1;
transform: scale(1);
}
.subtitle-bar {
position: fixed;
left: 50%;
bottom: 40px;
transform: translateX(-50%);
z-index: 20;
pointer-events: none;
padding: 10px 20px;
background: rgba(0, 0, 0, 0.2);
border-radius: 4px;
max-width: 80%;
}
.subtitle-text {
color: #fff;
font-size: 1.2rem;
text-align: center;
line-height: 1.5;
}
.fixed-btn-group {
position: fixed;
left: 32px;
bottom: 32px;
z-index: 30;
display: flex;
gap: 12px;
align-items: center;
}
.fixed-btn-group .el-button {
border-radius: 50px;
box-shadow: 0 2px 8px rgba(0,0,0,0.12);
padding: 12px 24px;
font-size: 18px;
}
/* 翻页动画 */
.slide-left-enter-active,
.slide-left-leave-active,
.slide-right-enter-active,
.slide-right-leave-active {
transition: all 0.5s ease;
}
.slide-left-enter {
transform: translateX(100%);
opacity: 0;
}
.slide-left-leave-to {
transform: translateX(-100%);
opacity: 0;
}
.slide-right-enter {
transform: translateX(-100%);
opacity: 0;
}
.slide-right-leave-to {
transform: translateX(100%);
opacity: 0;
}
/* 隐藏滚动条 */
body::-webkit-scrollbar, html::-webkit-scrollbar {
display: none;
}
/* 页数提示样式,可后续隐藏 */
#app > div[style*="color:red"] {
margin-bottom: 8px;
} }
#test{ #test{
margin: 80px; margin: 80px;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.content-wrapper {
display: flex;
flex-direction: column;
gap: 20px;
margin-bottom: 20px;
}
.image-container {
position: relative;
width: 100%;
background: #f5f5f5;
border-radius: 8px;
overflow: hidden;
}
.image-container img {
width: 100%;
height: auto;
display: block;
}
.highlight-rect {
position: absolute;
border: 2px solid #409EFF;
background-color: rgba(64, 158, 255, 0.1);
pointer-events: none;
transition: all 0.3s ease;
}
.subtitle-container {
min-height: 60px;
padding: 15px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
}
.subtitle-text {
font-size: 18px;
line-height: 1.5;
color: #333;
text-align: center;
}
.controls {
display: flex;
justify-content: center;
gap: 20px;
padding: 20px 0;
}
.controls .el-button {
min-width: 100px;
}
@media (max-width: 768px) {
.container {
padding: 10px;
}
.controls {
flex-direction: column;
align-items: center;
}
.controls .el-button {
width: 100%;
max-width: 300px;
}
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>h5-template-generator</title> <title>Book Player</title>
<link href="./index.css" rel="stylesheet" > <link href="./index.css" rel="stylesheet" >
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/jquery-1.12.3.min.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script> <script type="text/javascript" src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
...@@ -15,7 +15,31 @@ ...@@ -15,7 +15,31 @@
<script src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/index.js"></script> <script src="//teach.cdn.ireadabc.com/h5template/h5-static-lib/js/element-ui/index.js"></script>
</head> </head>
<body> <body>
<h1 id="test"></h1> <div id="app">
<div class="page-container">
<transition :name="pageTransition">
<div class="full-image-wrapper" :key="currentPage">
<img ref="mainImg" :src="pages[currentPage].image_url" :alt="'Page ' + pages[currentPage].page" v-if="pages.length" class="full-image"/>
<template v-if="currentRects && isRectVisible">
<div v-for="(rect, idx) in currentRects" :key="idx" class="rect-layer rect-visible" :style="getRectStyle(rect)"></div>
</template>
</div>
</transition>
</div>
<div class="subtitle-bar" v-if="currentAudioText">
<div class="subtitle-text">{{ currentAudioText }}</div>
</div>
<div class="fixed-btn-group">
<el-button icon="el-icon-arrow-left" @click="prevPage"></el-button>
<el-button
type="primary"
:icon="isPlaying ? 'el-icon-video-pause' : 'el-icon-video-play'"
@click="togglePlay">
{{ isPlaying ? '暂停' : '播放' }}
</el-button>
<el-button icon="el-icon-arrow-right" @click="nextPage"></el-button>
</div>
</div>
</body> </body>
<script src="./index.js"></script> <script src="./index.js"></script>
</html> </html>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment