This is not entirely dynamic, but I solved this problem by creating four different m3u8 playlists. I have designated each playlist to represent the quality of the stream (low, medium, high, extreme). The user will select one based on the desired maximum quality. The extreme playlist includes URLs of all qualities. A high playlist has fewer urls than the extreme, an average url less than a high, and less less urls than the medium. Whenever the user selects a different quality, I would simply switch the main streamโs playlist to the corresponding playlist URL.
Here is a simple example of four different playlists.
HLS_Movie_Extreme.m3u8
stream-0-64000/prog_index.m3u8
stream-1-350000/prog_index.m3u8
stream-2-800000/prog_index.m3u8
stream-3-1200000/index prog_index.m3u8 m3u8
stream-4-1800000/prog_index.m3u8
HLS_Movie_High.m3u8
stream-0-64000/prog_index.m3u8
stream-1-350000/prog_index.m3u8
stream-2-800000/prog_index.m3u8
stream-3-1200000/index prog_index.m3u8 m3u8
HLS_Movie_Medium.m3u8
stream-0-64000/prog_index.m3u8
stream-1-350000/prog_index.m3u8
stream-2-800000/prog_index.m3u8
HLS_Movie_Low.m3u8
stream-0-64000/prog_index.m3u8
stream-1-350000/prog_index.m3u8
, , . .