Skip to content

Support timezones in ISO8601 timestamps obtained from DASH UTCTiming elements #3524

@pstambrecht

Description

@pstambrecht

DashMediaSource class supports only "yyyy-MM-dd'T'HH:mm:ss'Z'" date format. Only one way how to change it is implement own custom DashMediaSource class. 806 lines of implementation for 1 line change. What about enable custom date format?

private static final class Iso8601Parser implements ParsingLoadable.Parser<Long> {

    @Override
    public Long parse(Uri uri, InputStream inputStream) throws IOException {
      String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine();
      try {
        // TODO: It may be necessary to handle timestamp offsets from UTC.
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        return format.parse(firstLine).getTime();
      } catch (ParseException e) {
        throw new ParserException(e);
      }
    }

  }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions