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 {
|
||||
return nil, errors.New("Invalid media playlist")
|
||||
}
|
||||
media.Segments = lo.Filter(media.Segments, func(seg *m3u8.MediaSegment, _ int) bool {
|
||||
return seg != nil
|
||||
})
|
||||
|
||||
if !bought {
|
||||
duration := 0
|
||||
for i, seg := range media.Segments {
|
||||
duration += int(seg.Duration)
|
||||
if duration >= 55 {
|
||||
media.Segments = media.Segments[:i]
|
||||
break
|
||||
media.Segments = lo.Map(media.Segments, func(seg *m3u8.MediaSegment, _ int) *m3u8.MediaSegment {
|
||||
if seg == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
duration += int(seg.Duration)
|
||||
if duration <= 55 {
|
||||
return seg
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
for _, seg := range media.Segments {
|
||||
if seg == nil {
|
||||
continue
|
||||
}
|
||||
// remove seg.URI ext, only keep the name
|
||||
name, ext := path.SplitNameExt(seg.URI)
|
||||
nameId, err := cast.ToInt64E(name)
|
||||
|
||||
Reference in New Issue
Block a user