diff --git a/resources/i18n/en-US/wiliwili.json b/resources/i18n/en-US/wiliwili.json index 545d5bc0..d10c6b37 100644 --- a/resources/i18n/en-US/wiliwili.json +++ b/resources/i18n/en-US/wiliwili.json @@ -13,6 +13,7 @@ "low_quality": "Low quality decoding (with less CPU usage)", "in_memory_cache": "Inmemory cache", "hwdec": "Hardware decode", + "auto_play": "Auto-play on video detail page", "exit_fullscreen": "Exit full screen at the end of playback", "play_strategy": "Play strategy", "auto_play_next_part": "Automatically playing next part", @@ -83,6 +84,7 @@ "opencc": "Automatically convert Simplified Chinese (restart required)", "keymap": { "header": "Keymap style", + "swap": "Swap AB/XY", "xbox": "Xbox", "ps": "PlayStation", "keyboard": "Keyboard" diff --git a/resources/i18n/zh-Hans/wiliwili.json b/resources/i18n/zh-Hans/wiliwili.json index bd338af6..db662f07 100644 --- a/resources/i18n/zh-Hans/wiliwili.json +++ b/resources/i18n/zh-Hans/wiliwili.json @@ -13,6 +13,7 @@ "low_quality": "低画质解码(以画质为代价换取更低的功耗)", "in_memory_cache": "解码缓存", "hwdec": "硬件解码", + "auto_play": "视频详情页直接播放", "exit_fullscreen": "播放结束时自动退出全屏", "play_strategy": "播放方式", "auto_play_next_part": "自动播放分集", @@ -83,6 +84,7 @@ "opencc": "自动转换简体中文 (需要重启)", "keymap": { "header": "键位图标 (需要重启)", + "swap": "键位交换", "xbox": "Xbox", "ps": "PlayStation", "keyboard": "键盘" diff --git a/resources/i18n/zh-Hant/wiliwili.json b/resources/i18n/zh-Hant/wiliwili.json index 955d5bae..ee90504f 100644 --- a/resources/i18n/zh-Hant/wiliwili.json +++ b/resources/i18n/zh-Hant/wiliwili.json @@ -13,6 +13,7 @@ "low_quality": "低畫質解碼(以畫質為代價換取更低的功耗)", "in_memory_cache": "解码緩存", "hwdec": "硬體解碼", + "auto_play": "影片詳細頁直接播放", "exit_fullscreen": "播放結束時自動退出全屏", "play_strategy": "播放方式", "auto_play_next_part": "自動播放分集", @@ -83,6 +84,7 @@ "opencc": "自動轉換簡體中文 (需要重啓)", "keymap": { "header": "鍵位風格 (需要重啟)", + "swap": "鍵位交換", "xbox": "Xbox", "ps": "PlayStation", "keyboard": "鍵盤" diff --git a/resources/xml/activity/setting_activity.xml b/resources/xml/activity/setting_activity.xml index 3c29710a..e838dc83 100644 --- a/resources/xml/activity/setting_activity.xml +++ b/resources/xml/activity/setting_activity.xml @@ -49,6 +49,9 @@ + + @@ -133,6 +136,9 @@ + + diff --git a/wiliwili/include/activity/setting_activity.hpp b/wiliwili/include/activity/setting_activity.hpp index 9299145e..bba36440 100644 --- a/wiliwili/include/activity/setting_activity.hpp +++ b/wiliwili/include/activity/setting_activity.hpp @@ -51,9 +51,11 @@ class SettingActivity : public brls::Activity { BRLS_BIND(BiliSelectorCell, selectorTexture, "setting/image/texture"); BRLS_BIND(BiliSelectorCell, selectorThreads, "setting/image/threads"); BRLS_BIND(BiliSelectorCell, selectorKeymap, "setting/keymap"); + BRLS_BIND(brls::BooleanCell, btnKeymapSwap, "setting/keymap_swap"); BRLS_BIND(brls::BooleanCell, btnOpencc, "setting/opencc"); BRLS_BIND(brls::BooleanCell, btnQuality, "setting/video/quality"); BRLS_BIND(brls::BooleanCell, btnHWDEC, "setting/video/hwdec"); + BRLS_BIND(brls::BooleanCell, btnAutoPlay, "setting/video/auto_play"); BRLS_BIND(BiliSelectorCell, selectorInmemory, "setting/video/inmemory"); BRLS_BIND(BiliSelectorCell, selectorFormat, "setting/video/format"); BRLS_BIND(BiliSelectorCell, selectorCodec, "setting/video/codec"); diff --git a/wiliwili/include/utils/config_helper.hpp b/wiliwili/include/utils/config_helper.hpp index 374f497a..c2b63373 100644 --- a/wiliwili/include/utils/config_helper.hpp +++ b/wiliwili/include/utils/config_helper.hpp @@ -39,6 +39,7 @@ enum class SettingItem { APP_SWAP_ABXY, // A-B 交换 和 X-Y 交换 SCROLL_SPEED, // 列表滑动速度 HISTORY_REPORT, + PLAYER_AUTO_PLAY, // 进入详情页自动播放 PLAYER_STRATEGY, PLAYER_BOTTOM_BAR, PLAYER_HIGHLIGHT_BAR, diff --git a/wiliwili/source/activity/setting_activity.cpp b/wiliwili/source/activity/setting_activity.cpp index e12141a7..2078d3e9 100644 --- a/wiliwili/source/activity/setting_activity.cpp +++ b/wiliwili/source/activity/setting_activity.cpp @@ -364,7 +364,7 @@ void SettingActivity::onContentAvailable() { brls::Application::getPlatform()->getVideoContext()->fullScreen(value); }); - auto setOnTopCell = [this](bool enabled){ + auto setOnTopCell = [this](bool enabled) { if (enabled) { cellOnTopMode->setDetailTextColor(brls::Application::getTheme()["brls/list/listItem_value_color"]); } else { @@ -481,6 +481,13 @@ void SettingActivity::onContentAvailable() { selectorKeymap->setVisibility(brls::Visibility::GONE); #endif + /// Swap ABXY + btnKeymapSwap->init("wiliwili/setting/app/others/keymap/swap"_i18n, conf.getBoolOption(SettingItem::APP_SWAP_ABXY), + [](bool data) { + ProgramConfig::instance().setSettingItem(SettingItem::APP_SWAP_ABXY, data); + brls::Application::setSwapInputKeys(data); + }); + /// App language static int langIndex = conf.getStringOptionIndex(SettingItem::APP_LANG); selectorLang->init("wiliwili/setting/app/others/language/header"_i18n, @@ -648,6 +655,13 @@ void SettingActivity::onContentAvailable() { }); #endif + /// Auto Play when open video detail page + btnAutoPlay->init("wiliwili/setting/app/playback/auto_play"_i18n, conf.getBoolOption(SettingItem::PLAYER_AUTO_PLAY), + [](bool value) { + ProgramConfig::instance().setSettingItem(SettingItem::PLAYER_AUTO_PLAY, value); + MPVCore::AUTO_PLAY = value; + }); + /// Decode quality btnQuality->init("wiliwili/setting/app/playback/low_quality"_i18n, conf.getBoolOption(SettingItem::PLAYER_LOW_QUALITY), [](bool value) { diff --git a/wiliwili/source/utils/config_helper.cpp b/wiliwili/source/utils/config_helper.cpp index 12b4b74d..6d1bd043 100644 --- a/wiliwili/source/utils/config_helper.cpp +++ b/wiliwili/source/utils/config_helper.cpp @@ -116,6 +116,7 @@ std::unordered_map ProgramConfig::SETTING_MAP = { {SettingItem::FULLSCREEN, {"fullscreen", {}, {}, 1}}, #endif {SettingItem::HISTORY_REPORT, {"history_report", {}, {}, 1}}, + {SettingItem::PLAYER_AUTO_PLAY, {"player_auto_play", {}, {}, 1}}, {SettingItem::PLAYER_BOTTOM_BAR, {"player_bottom_bar", {}, {}, 1}}, {SettingItem::PLAYER_HIGHLIGHT_BAR, {"player_highlight_bar", {}, {}, 0}}, {SettingItem::PLAYER_SKIP_OPENING_CREDITS, {"player_skip_opening_credits", {}, {}, 1}}, @@ -480,7 +481,7 @@ void ProgramConfig::load() { } // 加载完成后自动播放 - MPVCore::AUTO_PLAY = true; + MPVCore::AUTO_PLAY = getBoolOption(SettingItem::PLAYER_AUTO_PLAY); // 初始化默认的倍速设定 MPVCore::VIDEO_SPEED = getIntOption(SettingItem::PLAYER_DEFAULT_SPEED); diff --git a/wiliwili/source/view/mpv_core.cpp b/wiliwili/source/view/mpv_core.cpp index def4908b..c09e9a8d 100644 --- a/wiliwili/source/view/mpv_core.cpp +++ b/wiliwili/source/view/mpv_core.cpp @@ -467,6 +467,7 @@ void MPVCore::init() { sleepTime = std::chrono::system_clock::now(); pause(); // do not automatically play video + autoPlay = AUTO_PLAY; AUTO_PLAY = false; } }); @@ -847,6 +848,14 @@ void MPVCore::eventMainLoop() { mpvCoreEvent.fire(MpvEventEnum::UPDATE_PROGRESS); // 移除其他备用链接 command_async("playlist-clear"); + + if (AUTO_PLAY) { + mpvCoreEvent.fire(MpvEventEnum::MPV_RESUME); + this->resume(); + } else { + mpvCoreEvent.fire(MpvEventEnum::MPV_PAUSE); + this->pause(); + } break; case MPV_EVENT_START_FILE: // event 6: 开始加载文件 @@ -862,13 +871,6 @@ void MPVCore::eventMainLoop() { brls::Logger::info("========> MPV_EVENT_PLAYBACK_RESTART"); video_stopped = false; mpvCoreEvent.fire(MpvEventEnum::LOADING_END); - if (AUTO_PLAY) { - mpvCoreEvent.fire(MpvEventEnum::MPV_RESUME); - this->resume(); - } else { - mpvCoreEvent.fire(MpvEventEnum::MPV_PAUSE); - this->pause(); - } break; case MPV_EVENT_END_FILE: { // event 7: 文件播放结束