All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iheartradio.m3u8.TrackHandler Maven / Gradle / Ivy

package com.iheartradio.m3u8;

import com.iheartradio.m3u8.data.TrackData;

class TrackHandler implements LineHandler {
    @Override
    public void handle(String line, ParseState state) throws ParseException {
        final TrackData.Builder builder = new TrackData.Builder();
        final MediaParseState mediaState = state.getMedia();

        if (state.isExtended() && mediaState.trackInfo == null) {
            throw ParseException.create(ParseExceptionType.MISSING_TRACK_INFO, line);
        }

        if (Constants.URL_PATTERN.matcher(line).matches()) {
            builder.withUrl(line);
        } else {
            builder.withPath(line);
        }

        mediaState.tracks.add(builder
                .withTrackInfo(mediaState.trackInfo)
                .withEncryptionData(mediaState.encryptionData)
                .build());

        mediaState.trackInfo = null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy