grafov / m3u8

Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. :cinema:
http://tools.ietf.org/html/draft-pantos-http-live-streaming
BSD 3-Clause "New" or "Revised" License
1.22k stars 312 forks source link

set Segment key error #200

Open Ruk1ng001 opened 1 year ago

Ruk1ng001 commented 1 year ago

I get an error when all segments is nil in file reader.go:

        if state.tagKey {
            p.Segments[p.last()].Key = &Key{state.xkey.Method, state.xkey.URI, state.xkey.IV, state.xkey.Keyformat, state.xkey.Keyformatversions}
            // First EXT-X-KEY may appeared in the header of the playlist and linked to first segment
            // but for convenient playlist generation it also linked as default playlist key
            if p.Key == nil {
                p.Key = state.xkey
            }
            state.tagKey = false
        }

All the segment in p.Segments is nil, so cann't find p.Segments[p.last()].Key.