Comments (4)
Below is a hack temporary solution until @mangui has time to implement the above. I emphasize that this is a hack solution -- it works but you need to wait until the looping error event is fired before it recovers, so it's generally slow. It doesn't hurt to keep once the proper drift solution is implemented, as it offers a fallback recovery in case the looping crops up for other potential reasons:
var hls = new Hls();
var video = document.getElementById('your-video-id');
hls.attachVideo(video);
//...
hls.on(Hls.Events.ERROR, function (event, data) {
if (!data.fatal && data.details === Hls.ErrorDetails.FRAG_LOOP_LOADING_ERROR) {
seekToNearestBuffered();
}
});
function seekToNearestBuffered() {
var pos = video.currentTime,
closest = null,
smallestDiff = null,
start, diff;
console.log("[hlsjs] attempt to seek to nearest buffered area, currentTime:", pos);
for (var i = 0; i < video.buffered.length; i++) {
start = video.buffered.start(i);
diff = Math.abs(pos - start);
if (smallestDiff === null || diff < smallestDiff) {
closest = start;
smallestDiff = diff;
}
}
if (closest !== null) {
console.log("[hlsjs] seeking to closest buffered area start:", closest);
video.currentTime = closest;
}
}
from hls.js.
@matb33 your playlist should work, you can check on drift_refactor branch
@shacharz it should also fix the playback of https://livestream.peer5.com/video/soccer/index.m3u8
from hls.js.
closing as implemented
from hls.js.
So far this drift fix has been working great. We're running it through a beta period with several users and will let you know if we encounter issues.
from hls.js.
Related Issues (20)
- Improve Error Handling for "attachMedia" with Null HOT 1
- HE-AACv1 and v2 not working with iOS HOT 2
- GAP in a subtitle playlist causes switch to lowest quality level HOT 1
- Airplay streaming issue on ios HOT 13
- h264 stream not playing properly HOT 1
- DIFFERENCE IN FRAME HOT 3
- Dolby D+ not supported in TransportStream HOT 3
- x264 HDR video does not work in safari HOT 1
- Strange Sound Behavior on Ubuntu 24.04 and Multi-Channel Audio HOT 6
- A decode error occurs in Mac Safari. HOT 1
- Seeking to a previous frame, which is the last frame of the previous segment, hangs or seeks incorrectly HOT 7
- 使用hls.js播放hls时,视频出现了花屏 HOT 10
- Fill gaps with empty frames or last frame HOT 2
- Question about removing remuxEmptyAudio HOT 3
- Repeated QuotaExceededError HOT 2
- Same fragments loaded multiple times HOT 2
- Stop Loading Video Stream HOT 2
- A stream plays normally on the hls.js demo page, but in my own project, it stops playing after approximately 20 seconds HOT 3
- when multiple audio tracks are there, HLS quality option not trigerring HOT 1
- media key failed to execute HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hls.js.