androidx / androidx/media

Why mediaPos from eventLog increases negatively after getting #EXT-X-DISCONTINUITY-SEQUENCE?

Open
#2,592 4 comments 0 reactions 1 assignee View on GitHub

@tianyif is already working on this.

Since Jul 7, 2025.

question
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

What are we trying to achieve?
We aim to play HLS VOD streams using ExoPlayer. We tested the stream using the demo application from the Media3 GitHub repository. Our goal is to ensure smooth playback of the stream with ExoPlayer.

Current Behavior
In normal conditions, the stream plays smoothly. However, when the playlist contains the #EXT-X-DISCONTINUITY tag, the stream gets stuck after jumping the gap.

To provide more context:

  • We insert the #EXT-X-DISCONTINUITY tag when segments are missing in the playlist.

  • When #EXT-X-DISCONTINUITY tag is removed from the playlist , we are incrementing the #EXT-X-DISCONTINUITY-SEQUENCE.

ExoPlayer skips the time gap and plays for a few seconds but then freezes. During the freeze:

  • The buffering state is true.

  • The current mediaPos in the event log shows an increasing negative value.

  • onPositionDiscontinuity event does not gets called.

  • Some times error has been thrown from the player
    playerFailed [eventTime=47.16, mediaPos=-8.15, window=0, period=0, errorCode=ERROR_CODE_BEHIND_LIVE_WINDOW androidx.media3.exoplayer.ExoPlaybackException: Source error

  • When a error thrown only then the onPositionDiscontinuity called with reason 1.

Android OS:

  • Redmi note 10 pro with android version 13
  • Google pixel 6 with android version 16

Streams information:

  • Fixed bitrate
  • Fixed Resulation

M3U8 meta example:
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:29
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:18:54.074Z
#EXTINF:2.0,
1750742334074_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:18:56.054Z
#EXTINF:2.0,
1750742336054_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:18:58.054Z
#EXTINF:2.0,
1750742338054_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:19:00.068Z
#EXTINF:1.899,
1750742340068_1.899s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:29.047Z
#EXTINF:3.949267,
1750742429047_3.949267s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:30
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:18:56.054Z
#EXTINF:2.0,
1750742336054_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:18:58.054Z
#EXTINF:2.0,
1750742338054_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:19:00.068Z
#EXTINF:1.899,
1750742340068_1.899s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:29.047Z
#EXTINF:3.949267,
1750742429047_3.949267s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:48.652Z
#EXTINF:2.0,
1750742448652_2.0s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:31
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:18:58.054Z
#EXTINF:2.0,
1750742338054_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:19:00.068Z
#EXTINF:1.899,
1750742340068_1.899s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:29.047Z
#EXTINF:3.949267,
1750742429047_3.949267s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:48.652Z
#EXTINF:2.0,
1750742448652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:50.652Z
#EXTINF:2.0,
1750742450652_2.0s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:32
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:19:00.068Z
#EXTINF:1.899,
1750742340068_1.899s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:29.047Z
#EXTINF:3.949267,
1750742429047_3.949267s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:48.652Z
#EXTINF:2.0,
1750742448652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:50.652Z
#EXTINF:2.0,
1750742450652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:52.652Z
#EXTINF:2.0,
1750742452652_2.0s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:33
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:29.047Z
#EXTINF:3.949267,
1750742429047_3.949267s.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:48.652Z
#EXTINF:2.0,
1750742448652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:50.652Z
#EXTINF:2.0,
1750742450652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:52.652Z
#EXTINF:2.0,
1750742452652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:54.652Z
#EXTINF:2.0,
1750742454652_2.0s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:34
#EXT-X-DISCONTINUITY-SEQUENCE:1
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:48.652Z
#EXTINF:2.0,
1750742448652_2.0s.ts
#EXTINF:2.0,
1750742450652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:52.652Z
#EXTINF:2.0,
1750742452652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:54.652Z
#EXTINF:2.0,
1750742454652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:56.652Z
#EXTINF:2.0,
1750742456652_2.0s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:35
#EXT-X-DISCONTINUITY-SEQUENCE:1
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:50.652Z
#EXTINF:2.0,
1750742450652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:52.652Z
#EXTINF:2.0,
1750742452652_2.0s.ts
#EXTINF:2.0,
1750742454652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:56.652Z
#EXTINF:2.0,
1750742456652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:58.652Z
#EXTINF:3.95,
1750742458652_3.95s.ts

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:36
#EXT-X-DISCONTINUITY-SEQUENCE:1
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:52.652Z
#EXTINF:2.0,
1750742452652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:54.652Z
#EXTINF:2.0,
1750742454652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:56.652Z
#EXTINF:2.0,
1750742456652_2.0s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:20:58.652Z
#EXTINF:3.95,
1750742458652_3.95s.ts
#EXT-X-PROGRAM-DATE-TIME:2025-06-24T05:21:02.602Z
#EXTINF:2.0,
1750742462602_2.0s.ts

Players Able to play on this scenario:

  • Avplayer
  • HLS.js

What we are getting from the log from media3/ExoPlayer?

2025-07-07 14:34:24.482
timeline [eventTime=599.29, mediaPos=0.99, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:26.474
timeline [eventTime=601.28, mediaPos=0.97, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:28.465
timeline [eventTime=603.28, mediaPos=0.96, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:30.434
timeline [eventTime=605.24, mediaPos=0.93, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:32.458
timeline [eventTime=607.27, mediaPos=0.95, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:34.502
timeline [eventTime=609.31, mediaPos=0.99, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:36.500
timeline [eventTime=611.31, mediaPos=0.99, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:38.559
timeline [eventTime=613.37, mediaPos=1.09, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:40.426
timeline [eventTime=615.24, mediaPos=0.96, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:42.721
timeline [eventTime=617.53, mediaPos=1.24, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:44.500
timeline [eventTime=619.31, mediaPos=1.02, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:46.544
timeline [eventTime=621.35, mediaPos=-1362.64, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:48.500
timeline [eventTime=623.31, mediaPos=-1362.68, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:50.500
timeline [eventTime=625.31, mediaPos=-1362.69, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:52.500
timeline [eventTime=627.31, mediaPos=-1362.68, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:54.631
timeline [eventTime=629.44, mediaPos=-1362.56, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:56.487
timeline [eventTime=631.30, mediaPos=-1363.91, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:34:58.594
timeline [eventTime=633.40, mediaPos=-1365.92, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

2025-07-07 14:35:00.475
timeline [eventTime=635.28, mediaPos=-1367.91, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]
2025-07-07 14:35:02.502
timeline [eventTime=637.31, mediaPos=-1369.92, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE]

...........................................

At some stage the buffering state goes to buffering..

Question:

  • Why is mediaPos increasing negatively?
  • How can we solve the endless buffering issue in ExoPlayer?
  • Does onPositionDiscontinuity() trigger when encountering #EXT-X-DISCONTINUITY?
  • What player configurations can mitigate this issue?
  • Is this a known issue for ExoPlayer?

Thank you !

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.