Skip to content

Commit

Permalink
Player: Pause directly during network interruption during playback
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Dec 13, 2023
1 parent 67dda20 commit d4458e1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
12 changes: 10 additions & 2 deletions wiliwili/source/activity/player_base_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,17 @@ void BasePlayerActivity::setCommonData() {
// 尝试自动加载下一分集
// 如果当前最顶层是Dialog就放弃自动播放,因为有可能是用户点开了收藏或者投币对话框
{
// 播放到一半没网时也会触发EOF,这里简单判断一下进度是否符合
if (fabs(MPVCore::instance().video_progress -
MPVCore::instance().duration) > 2) {
brls::Logger::error("EOF: {}/{}",
MPVCore::instance().video_progress,
MPVCore::instance().duration);
return;
}
if (PLAYER_STRATEGY == PlayerStrategy::LOOP) {
MPVCore::instance().seek(0);
return ;
return;
}
auto stack = brls::Application::getActivitiesStack();
Activity* top = stack[stack.size() - 1];
Expand All @@ -353,7 +361,7 @@ void BasePlayerActivity::setCommonData() {
return;
}
if (PLAYER_STRATEGY == PlayerStrategy::NEXT ||
PLAYER_STRATEGY == PlayerStrategy::RCMD){
PLAYER_STRATEGY == PlayerStrategy::RCMD) {
this->onIndexChangeToNext();
}
}
Expand Down
34 changes: 22 additions & 12 deletions wiliwili/source/view/video_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ static int64_t getSeekRange(int64_t current) {
return current / 15;
}

#define CHECK_OSD(shake) \
if (is_osd_lock) { \
if (isOSDShown()) { \
brls::Application::giveFocus(this->osdLockBox); \
if (shake) this->osdLockBox->shakeHighlight(brls::FocusDirection::RIGHT); \
} else { \
this->showOSD(true); \
} \
return true; \
#define CHECK_OSD(shake) \
if (is_osd_lock) { \
if (isOSDShown()) { \
brls::Application::giveFocus(this->osdLockBox); \
if (shake) \
this->osdLockBox->shakeHighlight(brls::FocusDirection::RIGHT); \
} else { \
this->showOSD(true); \
} \
return true; \
}

VideoView::VideoView() {
Expand Down Expand Up @@ -866,12 +867,11 @@ void VideoView::toggleOSDLock() {
osdLockBox->setCustomNavigationRoute(FocusDirection::DOWN,
"video/osd/lock/box");
} else {
// 如果在锁定时,osdLockBox 获取到了焦点,通过点击进入了非锁定状态
// 避免上下按键不可用,手动设置上下按键的导航路线
// 手动设置上下按键的导航路线
osdLockBox->setCustomNavigationRoute(FocusDirection::UP,
"video/osd/setting");
osdLockBox->setCustomNavigationRoute(FocusDirection::DOWN,
"video/osd/toggle");
"video/osd/icon/box");
}
this->showOSD();
}
Expand Down Expand Up @@ -1391,6 +1391,16 @@ void VideoView::onChildFocusGained(View* directChild, View* focusedView) {
brls::Visibility::GONE) {
brls::Application::giveFocus(this);
}
static View* lastFocusedView = nullptr;

// 设定自定义导航
if (focusedView == this->btnSettingIcon) {
this->btnSettingIcon->setCustomNavigationRoute(
brls::FocusDirection::DOWN, lastFocusedView == this->btnToggle
? "video/osd/toggle"
: "video/osd/lock/box");
}
lastFocusedView = focusedView;
return;
}
brls::Application::giveFocus(this);
Expand Down

0 comments on commit d4458e1

Please sign in to comment.