feat: complete player
This commit is contained in:
Binary file not shown.
@@ -272,22 +272,26 @@ func (svc *Service) GetM3U8(ctx context.Context, tenantId int64, types pg.MediaT
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("Invalid media playlist")
|
return nil, errors.New("Invalid media playlist")
|
||||||
}
|
}
|
||||||
media.Segments = lo.Filter(media.Segments, func(seg *m3u8.MediaSegment, _ int) bool {
|
|
||||||
return seg != nil
|
|
||||||
})
|
|
||||||
|
|
||||||
if !bought {
|
if !bought {
|
||||||
duration := 0
|
duration := 0
|
||||||
for i, seg := range media.Segments {
|
media.Segments = lo.Map(media.Segments, func(seg *m3u8.MediaSegment, _ int) *m3u8.MediaSegment {
|
||||||
duration += int(seg.Duration)
|
if seg == nil {
|
||||||
if duration >= 55 {
|
return nil
|
||||||
media.Segments = media.Segments[:i]
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
duration += int(seg.Duration)
|
||||||
|
if duration <= 55 {
|
||||||
|
return seg
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, seg := range media.Segments {
|
for _, seg := range media.Segments {
|
||||||
|
if seg == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// remove seg.URI ext, only keep the name
|
// remove seg.URI ext, only keep the name
|
||||||
name, ext := path.SplitNameExt(seg.URI)
|
name, ext := path.SplitNameExt(seg.URI)
|
||||||
nameId, err := cast.ToInt64E(name)
|
nameId, err := cast.ToInt64E(name)
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<van-nav-bar :title="item.title" left-text="返回" left-arrow @click-left="onClickLeft" />
|
<van-nav-bar :title="item.title" left-text="返回" left-arrow @click-left="onClickLeft" />
|
||||||
<div style="background-color: black;">
|
<video id="video" :poster="item.poster"></video>
|
||||||
<video id="video" :poster="item.poster"></video>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template v-if="false === item.bought">
|
<template v-if="false === item.bought">
|
||||||
<van-notice-bar left-icon="volume-o" text="未购买的视频、音频默认播放时长为1分钟左右。" />
|
<van-notice-bar left-icon="volume-o" text="未购买的视频、音频默认播放时长为1分钟左右。" />
|
||||||
<van-button square type="success" @click="buy()" size="large" block>
|
<van-button square type="warning" @click="buy()" size="large" block>
|
||||||
花费 {{ item.price * item.discount / 100 }} 点 立即购买
|
花费 {{ item.price * item.discount / 100 }} 点 立即购买
|
||||||
</van-button>
|
</van-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -16,30 +14,26 @@
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
<van-space direction="vertical" fill size="2rem">
|
<van-space direction="vertical" fill size="2rem">
|
||||||
|
|
||||||
|
|
||||||
<van-row gutter="20">
|
|
||||||
<van-col span="12">
|
|
||||||
<van-button type="primary" plain round @click="play(item.hash, 'video')" size="large" block>看视频</van-button>
|
|
||||||
</van-col>
|
|
||||||
<van-col span="12">
|
|
||||||
<van-button type="warning" plain round="" @click="play(item.hash, 'audio')" size="large"
|
|
||||||
block>听音频</van-button>
|
|
||||||
</van-col>
|
|
||||||
</van-row>
|
|
||||||
|
|
||||||
<template v-if="playing">
|
<template v-if="playing">
|
||||||
<van-row gutter="20">
|
<van-row>
|
||||||
<van-col span="24">
|
|
||||||
<van-progress :percent="(currentTime / duration) * 100" />
|
|
||||||
</van-col>
|
|
||||||
</van-row>
|
|
||||||
<van-row gutter="20">
|
|
||||||
<van-col span="24">
|
<van-col span="24">
|
||||||
<van-button round type="danger" @click="stop()" size="large" block>结束播放</van-button>
|
<van-button round type="danger" @click="stop()" size="large" block>结束播放</van-button>
|
||||||
</van-col>
|
</van-col>
|
||||||
</van-row>
|
</van-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<van-row gutter="20">
|
||||||
|
<van-col span="12">
|
||||||
|
<van-button type="primary" plain round @click="play(item.hash, 'video')" size="large" block>看视频</van-button>
|
||||||
|
</van-col>
|
||||||
|
<van-col span="12">
|
||||||
|
<van-button type="warning" plain round="" @click="play(item.hash, 'audio')" size="large"
|
||||||
|
block>听音频</van-button>
|
||||||
|
</van-col>
|
||||||
|
</van-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
</van-space>
|
</van-space>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -146,7 +140,8 @@ const formatTime = (time) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#video {
|
#video {
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 4 / 3;
|
aspect-ratio: 4 / 3;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: fill;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user