As pointed by Paul B Mahol <onemda@gmail.com> the previous code could lead to null pointer dereference.
Provide a way to wrap around the segment index so pseudostreaming live through a web server and html5 browser is simpler. Also ensure that 0 (disable) is a valid value across the options providing wrap around.
It behaves similarly to image2 muxer