mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-05-23 22:37:41 +08:00
新增设置-基本设置-启动时自动播放音乐
This commit is contained in:
parent
ad3fd66a44
commit
02a8d8422f
7
index.js
7
index.js
@ -117,7 +117,12 @@ const init = () => {
|
||||
|
||||
return
|
||||
}
|
||||
global.restorePlayInfo = info
|
||||
|
||||
let setting = store.getState().common.setting
|
||||
global.restorePlayInfo = {
|
||||
info,
|
||||
startupAutoPlay: setting.startupAutoPlay,
|
||||
}
|
||||
|
||||
store.dispatch(playerAction.setList({
|
||||
list: {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
- 新增设置-桌面歌词-单行歌词设置,默认关闭,启用后只显示一行歌词,超出窗口宽度自动滚动到末尾
|
||||
- 新增设置-桌面歌词-显示歌词切换动画,默认启用,如果你觉得切换动画影响视觉可以将其关闭
|
||||
- 新增设置-基本设置-启动后自动播放音乐,默认关闭
|
||||
|
||||
### 优化
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
import { MUSIC_TOGGLE_MODE } from './constant'
|
||||
|
||||
const defaultSetting = {
|
||||
version: '1.24',
|
||||
version: '1.25',
|
||||
player: {
|
||||
togglePlayMethod: MUSIC_TOGGLE_MODE.listLoop,
|
||||
highQuality: false,
|
||||
@ -113,6 +113,7 @@ const defaultSetting = {
|
||||
// randomAnimate: true,
|
||||
ignoreVersion: null,
|
||||
isAgreePact: false,
|
||||
startupAutoPlay: false,
|
||||
}
|
||||
|
||||
const overwriteSetting = {
|
||||
|
@ -123,6 +123,7 @@
|
||||
"setting_backup_part_import_setting": "Import settings",
|
||||
"setting_backup_part_import_setting_desc": "Select the Settings file",
|
||||
"setting_basic": "General",
|
||||
"setting_basic__startup_auto_play": "Play music automatically after startup",
|
||||
"setting_basic_animation": "Random pop-up animation",
|
||||
"setting_basic_lang": "Language",
|
||||
"setting_basic_share_type": "Share",
|
||||
|
@ -52,8 +52,8 @@
|
||||
"list_import_part_button_confirm": "覆盖掉",
|
||||
"list_import_part_confirm": "导入的列表({{importName}})与本地列表({{localName}})的ID相同,是否覆盖本地列表?",
|
||||
"list_import_part_desc": "选择列表文件",
|
||||
"list_import_tip__failed": "导入失败",
|
||||
"list_import_tip__alldata": "这是一个所有数据备份文件,你需要去这里导入:\n设置 -> 备份与恢复 -> 列表数据 -> 导入列表",
|
||||
"list_import_tip__failed": "导入失败",
|
||||
"list_import_tip__playlist": "这是一个列表备份文件,你需要去这里导入:\n设置 -> 备份与恢复 -> 列表数据 -> 导入列表",
|
||||
"list_import_tip__playlist_part": "这是一个单列表文件,你需要去这里导入:\n我的列表 -> 点击任意一个列表名右侧的菜单按钮 -> 在弹出的菜单中选择导入",
|
||||
"list_import_tip__setting": "这是一个设置备份文件,移动端不支持导入此类文件",
|
||||
@ -124,6 +124,7 @@
|
||||
"setting_backup_part_import_setting": "导入设置",
|
||||
"setting_backup_part_import_setting_desc": "选择配置文件",
|
||||
"setting_basic": "基本设置",
|
||||
"setting_basic__startup_auto_play": "启动后自动播放音乐",
|
||||
"setting_basic_animation": "弹出层随机动画",
|
||||
"setting_basic_lang": "语言",
|
||||
"setting_basic_share_type": "分享方式",
|
||||
|
@ -2,6 +2,7 @@ import TrackPlayer, { State } from 'react-native-track-player'
|
||||
import BackgroundTimer from 'react-native-background-timer'
|
||||
import { defaultUrl } from '@/config'
|
||||
import { getStore } from '@/store'
|
||||
import { action as playerAction } from '@/store/modules/player'
|
||||
|
||||
const store = getStore()
|
||||
const list = []
|
||||
@ -98,7 +99,10 @@ export const playMusic = async(tracks, time) => {
|
||||
if (time) await TrackPlayer.seekTo(time)
|
||||
if (global.restorePlayInfo) {
|
||||
await TrackPlayer.pause()
|
||||
let startupAutoPlay = global.restorePlayInfo.startupAutoPlay
|
||||
global.restorePlayInfo = null
|
||||
|
||||
if (startupAutoPlay) store.dispatch(playerAction.playMusic())
|
||||
} else {
|
||||
await TrackPlayer.play()
|
||||
}
|
||||
|
20
src/screens/Home/Setting/Basic/IsStartupAutoPlay.js
Normal file
20
src/screens/Home/Setting/Basic/IsStartupAutoPlay.js
Normal file
@ -0,0 +1,20 @@
|
||||
import React, { memo } from 'react'
|
||||
import { View } from 'react-native'
|
||||
|
||||
import { useGetter, useDispatch } from '@/store'
|
||||
|
||||
import CheckBoxItem from '../components/CheckBoxItem'
|
||||
import { useTranslation } from '@/plugins/i18n'
|
||||
|
||||
export default memo(() => {
|
||||
const { t } = useTranslation()
|
||||
const startupAutoPlay = useGetter('common', 'startupAutoPlay')
|
||||
const setStartupAutoPlay = useDispatch('common', 'setStartupAutoPlay')
|
||||
|
||||
|
||||
return (
|
||||
<View style={{ marginTop: 5, marginBottom: 15 }}>
|
||||
<CheckBoxItem check={startupAutoPlay} label={t('setting_basic__startup_auto_play')} onChange={setStartupAutoPlay} />
|
||||
</View>
|
||||
)
|
||||
})
|
@ -6,6 +6,7 @@ import Source from './Source'
|
||||
import SourceName from './SourceName'
|
||||
import Language from './Language'
|
||||
import ShareType from './ShareType'
|
||||
import IsStartupAutoPlay from './IsStartupAutoPlay'
|
||||
import { useTranslation } from '@/plugins/i18n'
|
||||
|
||||
export default memo(() => {
|
||||
@ -15,6 +16,7 @@ export default memo(() => {
|
||||
return (
|
||||
<Section title={t('setting_basic')}>
|
||||
<Theme />
|
||||
<IsStartupAutoPlay />
|
||||
<Source />
|
||||
<Language />
|
||||
<SourceName />
|
||||
|
@ -19,6 +19,7 @@ export const TYPES = {
|
||||
setNavScreenName: null,
|
||||
setPlayNextMode: null,
|
||||
setPrevSelectListId: null,
|
||||
setStartupAutoPlay: null,
|
||||
setApiSource: null,
|
||||
setTheme: null,
|
||||
setIsAutoTheme: null,
|
||||
@ -174,6 +175,15 @@ export const setPlayNextMode = mode => async(dispatch, getState) => {
|
||||
await setData(settingKey, state.common.setting)
|
||||
}
|
||||
|
||||
export const setStartupAutoPlay = enable => async(dispatch, getState) => {
|
||||
dispatch({
|
||||
type: TYPES.setStartupAutoPlay,
|
||||
payload: enable,
|
||||
})
|
||||
const { common } = getState()
|
||||
await setData(settingKey, common.setting)
|
||||
}
|
||||
|
||||
export const setApiSource = id => async(dispatch, getState) => {
|
||||
dispatch({
|
||||
type: TYPES.setApiSource,
|
||||
|
@ -11,6 +11,8 @@ export const common = state => state.common
|
||||
export const navMenus = state => state.common.nav.menus
|
||||
export const navActiveIndex = state => state.common.nav.activeIndex
|
||||
|
||||
export const startupAutoPlay = state => state.common.setting.startupAutoPlay
|
||||
|
||||
export const setting = state => state.common.setting
|
||||
|
||||
export const componentIds = state => state.common.componentIds
|
||||
|
@ -258,6 +258,15 @@ const mutations = {
|
||||
},
|
||||
}
|
||||
},
|
||||
[TYPES.setStartupAutoPlay](state, startupAutoPlay) {
|
||||
return {
|
||||
...state,
|
||||
setting: {
|
||||
...state.setting,
|
||||
startupAutoPlay,
|
||||
},
|
||||
}
|
||||
},
|
||||
[TYPES.setPlayerCacheSize](state, size) {
|
||||
return {
|
||||
...state,
|
||||
|
@ -430,7 +430,7 @@ export const refreshMusicUrl = (musicInfo, restorePlayTime) => (dispatch, getSta
|
||||
}
|
||||
const songmid = targetMusic.songmid
|
||||
const index = state.player.listInfo.list.findIndex(m => m.songmid == songmid)
|
||||
handlePlayMusic({
|
||||
return handlePlayMusic({
|
||||
getState,
|
||||
dispatch,
|
||||
index,
|
||||
|
Loading…
x
Reference in New Issue
Block a user