diff --git a/plugin/hls/index.go b/plugin/hls/index.go index de88bb79eb499c1cd1041d2a398a32a235238bff..642c195e0e58c90ec381a7a70460623880c584ab 100644 --- a/plugin/hls/index.go +++ b/plugin/hls/index.go @@ -95,7 +95,7 @@ func (config *HLSPlugin) vod(w http.ResponseWriter, r *http.Request) { switch recordType { case "fmp4": query := `stream_path = ? AND type = ? AND start_time IS NOT NULL AND end_time IS NOT NULL AND ? <= end_time AND ? >= start_time` - config.DB.Where(query, streamPath, "mp4", startTime, endTime).Find(&records) + config.DB.Where(query, streamPath, "mp4", startTime, endTime).Order("start_time ASC").Find(&records) if len(records) == 0 { return } @@ -139,7 +139,7 @@ func (config *HLSPlugin) vod(w http.ResponseWriter, r *http.Request) { return } query := `stream_path = ? AND type = ? AND start_time IS NOT NULL AND end_time IS NOT NULL AND ? <= end_time AND ? >= start_time` - config.DB.Where(query, streamPath, recordType, startTime, endTime).Find(&records) + config.DB.Where(query, streamPath, recordType, startTime, endTime).Order("start_time ASC").Find(&records) if len(records) > 0 { playlist := hls.Playlist{ Version: 7, @@ -230,7 +230,7 @@ func (config *HLSPlugin) ServeHTTP(w http.ResponseWriter, r *http.Request) { if config.DB != nil { var records []m7s.RecordStream query := `stream_path = ? AND type = 'ts' AND start_time IS NOT NULL AND end_time IS NOT NULL AND ? <= end_time AND ? >= start_time` - config.DB.Where(query, streamPath, startTime, endTime).Find(&records) + config.DB.Where(query, streamPath, startTime, endTime).Order("start_time ASC").Find(&records) if len(records) > 0 { playlist := hls.Playlist{