mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-16 13:05:59 +08:00
Co-authored-by: xia-chu <771730766@qq.com>
This commit is contained in:
@@ -71,6 +71,11 @@ void HlsPlayer::teardown() {
|
||||
|
||||
void HlsPlayer::fetchSegment() {
|
||||
if (_ts_list.empty()) {
|
||||
// 如果是点播文件,播放列表为空代表文件播放结束,关闭播放器: #2628
|
||||
if(!HlsParser::isLive()){
|
||||
teardown();
|
||||
return;
|
||||
}
|
||||
//播放列表为空,那么立即重新下载m3u8文件
|
||||
_timer.reset();
|
||||
fetchIndexFile();
|
||||
@@ -121,18 +126,21 @@ void HlsPlayer::fetchSegment() {
|
||||
WarnL << "Download ts segment " << url << " failed:" << err;
|
||||
if (err.getErrCode() == Err_timeout) {
|
||||
strong_self->_timeout_multiple = MAX(strong_self->_timeout_multiple + 1, MAX_TIMEOUT_MULTIPLE);
|
||||
}else{
|
||||
strong_self->_timeout_multiple = MAX(strong_self->_timeout_multiple -1 , MIN_TIMEOUT_MULTIPLE);
|
||||
} else {
|
||||
strong_self->_timeout_multiple = MAX(strong_self->_timeout_multiple - 1, MIN_TIMEOUT_MULTIPLE);
|
||||
}
|
||||
}
|
||||
//提前半秒下载好
|
||||
auto delay = duration - ticker.elapsedTime() / 1000.0f - 0.5;
|
||||
if (delay <= 0) {
|
||||
//延时最小10ms
|
||||
delay = 10;
|
||||
// 提前0.5秒下载好,支持点播文件控制下载速度: #2628
|
||||
auto delay = duration - 0.5 - ticker.elapsedTime() / 1000.0f;
|
||||
if (delay > 2.0) {
|
||||
// 提前1秒下载
|
||||
delay -= 1.0;
|
||||
} else if (delay <= 0) {
|
||||
// 延时最小10ms
|
||||
delay = 0.01;
|
||||
}
|
||||
//延时下载下一个切片
|
||||
strong_self->_timer_ts.reset(new Timer(delay / 1000.0f, [weak_self]() {
|
||||
// 延时下载下一个切片
|
||||
strong_self->_timer_ts.reset(new Timer(delay, [weak_self]() {
|
||||
auto strong_self = weak_self.lock();
|
||||
if (strong_self) {
|
||||
strong_self->fetchSegment();
|
||||
|
||||
Reference in New Issue
Block a user