apm-react-audio-player 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -143,6 +143,17 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
143
143
  var play = function play() {
144
144
  setIsPlaying(true);
145
145
  setIsFinishedPlaying(false);
146
+
147
+ // For live streams (duration === Infinity), reset the audio element before
148
+ // playing. The audioSrc useEffect in ReactAudioPlayerInner calls load() on
149
+ // mount, which causes the browser to pre-buffer the HLS stream. By the time
150
+ // the user clicks play the manifest's seekable window has moved forward and
151
+ // old segments are gone, so the browser auto-seeks to the earliest available
152
+ // position (e.g. 20s in), causing ads to start mid-stream. Calling load()
153
+ // here reconnects to the current live edge and gets a fresh manifest.
154
+ if (duration === Infinity) {
155
+ audioRef.current.load();
156
+ }
146
157
  audioRef.current.play();
147
158
 
148
159
  // Only start RAF loop for non-live streams with valid duration
@@ -141,6 +141,17 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
141
141
  var play = function play() {
142
142
  setIsPlaying(true);
143
143
  setIsFinishedPlaying(false);
144
+
145
+ // For live streams (duration === Infinity), reset the audio element before
146
+ // playing. The audioSrc useEffect in ReactAudioPlayerInner calls load() on
147
+ // mount, which causes the browser to pre-buffer the HLS stream. By the time
148
+ // the user clicks play the manifest's seekable window has moved forward and
149
+ // old segments are gone, so the browser auto-seeks to the earliest available
150
+ // position (e.g. 20s in), causing ads to start mid-stream. Calling load()
151
+ // here reconnects to the current live edge and gets a fresh manifest.
152
+ if (duration === Infinity) {
153
+ audioRef.current.load();
154
+ }
144
155
  audioRef.current.play();
145
156
 
146
157
  // Only start RAF loop for non-live streams with valid duration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apm-react-audio-player",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "author": "Jason Phan <jphan@mpr.org>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -27,9 +27,6 @@
27
27
  "prettier:fix": "prettier --check '**/**.js' --write",
28
28
  "clean": "rm -rf node_modules dist package-lock.json yarn.lock"
29
29
  },
30
- "assert": {
31
- "type": "json"
32
- },
33
30
  "peerDependencies": {
34
31
  "react": "^16.0.0"
35
32
  },
@@ -85,6 +82,8 @@
85
82
  ],
86
83
  "jest": {
87
84
  "testEnvironment": "jsdom",
88
- "setupFilesAfterEnv": ["<rootDir>/jest.setup.js"]
85
+ "setupFilesAfterEnv": [
86
+ "<rootDir>/jest.setup.js"
87
+ ]
89
88
  }
90
89
  }