mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 16:18:56 +08:00
现在即使切歌模式处于单曲循环、顺序播放、禁用时,手动切歌将会按照列表循环的规则处理(#69)
This commit is contained in:
parent
f84ec37ec9
commit
829c296f98
@ -5,6 +5,10 @@
|
|||||||
- 新增是否在通知栏显示歌曲图片设置,默认开启(原来的行为)
|
- 新增是否在通知栏显示歌曲图片设置,默认开启(原来的行为)
|
||||||
- 新增黑色皮肤“黑灯瞎火”
|
- 新增黑色皮肤“黑灯瞎火”
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 现在即使切歌模式处于单曲循环、顺序播放、禁用时,手动切歌将会按照列表循环的规则处理(#69)
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复wy源搜索某些歌曲时第一页之后的歌曲无法加载的问题
|
- 修复wy源搜索某些歌曲时第一页之后的歌曲无法加载的问题
|
||||||
|
@ -25,3 +25,19 @@ export const NAV_VIEW_NAMES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const LXM_FILE_EXT_RXP = /\.(json|lxmc)$/
|
export const LXM_FILE_EXT_RXP = /\.(json|lxmc)$/
|
||||||
|
|
||||||
|
export const MUSIC_TOGGLE_MODE = {
|
||||||
|
listLoop: 'listLoop', // 列表循环
|
||||||
|
random: 'random', // 列表随机
|
||||||
|
list: 'list', // 顺序播放
|
||||||
|
singleLoop: 'singleLoop', // 单曲循环
|
||||||
|
none: 'none', // 禁用
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MUSIC_TOGGLE_MODE_LIST = [
|
||||||
|
MUSIC_TOGGLE_MODE.listLoop,
|
||||||
|
MUSIC_TOGGLE_MODE.random,
|
||||||
|
MUSIC_TOGGLE_MODE.list,
|
||||||
|
MUSIC_TOGGLE_MODE.singleLoop,
|
||||||
|
MUSIC_TOGGLE_MODE.none,
|
||||||
|
]
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// const path = require('path')
|
// const path = require('path')
|
||||||
// const os = require('os')
|
// const os = require('os')
|
||||||
// const { isMac } = require('./utils')
|
// const { isMac } = require('./utils')
|
||||||
|
import { MUSIC_TOGGLE_MODE } from './constant'
|
||||||
|
|
||||||
const defaultSetting = {
|
const defaultSetting = {
|
||||||
version: '1.18',
|
version: '1.18',
|
||||||
player: {
|
player: {
|
||||||
togglePlayMethod: 'listLoop',
|
togglePlayMethod: MUSIC_TOGGLE_MODE.listLoop,
|
||||||
highQuality: false,
|
highQuality: false,
|
||||||
isSavePlayTime: false,
|
isSavePlayTime: false,
|
||||||
cacheSize: 1024, // unit MB
|
cacheSize: 1024, // unit MB
|
||||||
|
@ -105,7 +105,7 @@ export default async() => {
|
|||||||
|
|
||||||
TrackPlayer.addEventListener(TPEvent.PlaybackState, async info => {
|
TrackPlayer.addEventListener(TPEvent.PlaybackState, async info => {
|
||||||
const state = store.getState()
|
const state = store.getState()
|
||||||
console.log('playback-state', TPState[info.state])
|
// console.log('playback-state', TPState[info.state])
|
||||||
|
|
||||||
// console.log((await getCurrentTrack())?.id)
|
// console.log((await getCurrentTrack())?.id)
|
||||||
if (state.player.isGettingUrl) return
|
if (state.player.isGettingUrl) return
|
||||||
@ -187,7 +187,7 @@ export default async() => {
|
|||||||
if (retryTrack) {
|
if (retryTrack) {
|
||||||
if (retryTrack.musicId == retryGetUrlId) {
|
if (retryTrack.musicId == retryGetUrlId) {
|
||||||
if (++retryGetUrlNum > 1) {
|
if (++retryGetUrlNum > 1) {
|
||||||
store.dispatch(playerAction.playNext())
|
store.dispatch(playerAction.playNext(true))
|
||||||
retryGetUrlId = null
|
retryGetUrlId = null
|
||||||
retryTrack = null
|
retryTrack = null
|
||||||
return
|
return
|
||||||
@ -198,7 +198,7 @@ export default async() => {
|
|||||||
}
|
}
|
||||||
store.dispatch(playerAction.refreshMusicUrl(global.playInfo.currentPlayMusicInfo, errorTime))
|
store.dispatch(playerAction.refreshMusicUrl(global.playInfo.currentPlayMusicInfo, errorTime))
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(playerAction.playNext())
|
store.dispatch(playerAction.playNext(true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // if (!info.nextTrack) return
|
// // if (!info.nextTrack) return
|
||||||
|
@ -4,12 +4,7 @@ import { Icon } from '@/components/common/Icon'
|
|||||||
import { useGetter, useDispatch } from '@/store'
|
import { useGetter, useDispatch } from '@/store'
|
||||||
import { toast } from '@/utils/tools'
|
import { toast } from '@/utils/tools'
|
||||||
import { useTranslation } from '@/plugins/i18n'
|
import { useTranslation } from '@/plugins/i18n'
|
||||||
const playNextModes = [
|
import { MUSIC_TOGGLE_MODE_LIST, MUSIC_TOGGLE_MODE } from '@/config/constant'
|
||||||
'listLoop',
|
|
||||||
'random',
|
|
||||||
'list',
|
|
||||||
'singleLoop',
|
|
||||||
]
|
|
||||||
|
|
||||||
export default memo(({ width }) => {
|
export default memo(({ width }) => {
|
||||||
const togglePlayMethod = useGetter('common', 'togglePlayMethod')
|
const togglePlayMethod = useGetter('common', 'togglePlayMethod')
|
||||||
@ -18,22 +13,22 @@ export default memo(({ width }) => {
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const toggleNextPlayMode = () => {
|
const toggleNextPlayMode = () => {
|
||||||
let index = playNextModes.indexOf(togglePlayMethod)
|
let index = MUSIC_TOGGLE_MODE_LIST.indexOf(togglePlayMethod)
|
||||||
if (++index >= playNextModes.length) index = -1
|
if (++index >= MUSIC_TOGGLE_MODE_LIST.length) index = 0
|
||||||
const mode = playNextModes[index]
|
const mode = MUSIC_TOGGLE_MODE_LIST[index]
|
||||||
setPlayNextMode(mode || '')
|
setPlayNextMode(mode || '')
|
||||||
let modeName
|
let modeName
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'listLoop':
|
case MUSIC_TOGGLE_MODE.listLoop:
|
||||||
modeName = 'play_list_loop'
|
modeName = 'play_list_loop'
|
||||||
break
|
break
|
||||||
case 'random':
|
case MUSIC_TOGGLE_MODE.random:
|
||||||
modeName = 'play_list_random'
|
modeName = 'play_list_random'
|
||||||
break
|
break
|
||||||
case 'list':
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
modeName = 'play_list_order'
|
modeName = 'play_list_order'
|
||||||
break
|
break
|
||||||
case 'singleLoop':
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
modeName = 'play_single_loop'
|
modeName = 'play_single_loop'
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@ -46,16 +41,16 @@ export default memo(({ width }) => {
|
|||||||
const playModeIcon = useMemo(() => {
|
const playModeIcon = useMemo(() => {
|
||||||
let playModeIcon = null
|
let playModeIcon = null
|
||||||
switch (togglePlayMethod) {
|
switch (togglePlayMethod) {
|
||||||
case 'listLoop':
|
case MUSIC_TOGGLE_MODE.listLoop:
|
||||||
playModeIcon = 'list-loop'
|
playModeIcon = 'list-loop'
|
||||||
break
|
break
|
||||||
case 'random':
|
case MUSIC_TOGGLE_MODE.random:
|
||||||
playModeIcon = 'list-random'
|
playModeIcon = 'list-random'
|
||||||
break
|
break
|
||||||
case 'list':
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
playModeIcon = 'list-order'
|
playModeIcon = 'list-order'
|
||||||
break
|
break
|
||||||
case 'singleLoop':
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
playModeIcon = 'single-loop'
|
playModeIcon = 'single-loop'
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -4,12 +4,7 @@ import { Icon } from '@/components/common/Icon'
|
|||||||
import { useGetter, useDispatch } from '@/store'
|
import { useGetter, useDispatch } from '@/store'
|
||||||
import { toast } from '@/utils/tools'
|
import { toast } from '@/utils/tools'
|
||||||
import { useTranslation } from '@/plugins/i18n'
|
import { useTranslation } from '@/plugins/i18n'
|
||||||
const playNextModes = [
|
import { MUSIC_TOGGLE_MODE_LIST, MUSIC_TOGGLE_MODE } from '@/config/constant'
|
||||||
'listLoop',
|
|
||||||
'random',
|
|
||||||
'list',
|
|
||||||
'singleLoop',
|
|
||||||
]
|
|
||||||
|
|
||||||
export default memo(() => {
|
export default memo(() => {
|
||||||
const togglePlayMethod = useGetter('common', 'togglePlayMethod')
|
const togglePlayMethod = useGetter('common', 'togglePlayMethod')
|
||||||
@ -18,22 +13,22 @@ export default memo(() => {
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const toggleNextPlayMode = () => {
|
const toggleNextPlayMode = () => {
|
||||||
let index = playNextModes.indexOf(togglePlayMethod)
|
let index = MUSIC_TOGGLE_MODE_LIST.indexOf(togglePlayMethod)
|
||||||
if (++index >= playNextModes.length) index = -1
|
if (++index >= MUSIC_TOGGLE_MODE_LIST.length) index = 0
|
||||||
const mode = playNextModes[index]
|
const mode = MUSIC_TOGGLE_MODE_LIST[index]
|
||||||
setPlayNextMode(mode || '')
|
setPlayNextMode(mode)
|
||||||
let modeName
|
let modeName
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'listLoop':
|
case MUSIC_TOGGLE_MODE.listLoop:
|
||||||
modeName = 'play_list_loop'
|
modeName = 'play_list_loop'
|
||||||
break
|
break
|
||||||
case 'random':
|
case MUSIC_TOGGLE_MODE.random:
|
||||||
modeName = 'play_list_random'
|
modeName = 'play_list_random'
|
||||||
break
|
break
|
||||||
case 'list':
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
modeName = 'play_list_order'
|
modeName = 'play_list_order'
|
||||||
break
|
break
|
||||||
case 'singleLoop':
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
modeName = 'play_single_loop'
|
modeName = 'play_single_loop'
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@ -46,16 +41,16 @@ export default memo(() => {
|
|||||||
const playModeIcon = useMemo(() => {
|
const playModeIcon = useMemo(() => {
|
||||||
let playModeIcon = null
|
let playModeIcon = null
|
||||||
switch (togglePlayMethod) {
|
switch (togglePlayMethod) {
|
||||||
case 'listLoop':
|
case MUSIC_TOGGLE_MODE.listLoop:
|
||||||
playModeIcon = 'list-loop'
|
playModeIcon = 'list-loop'
|
||||||
break
|
break
|
||||||
case 'random':
|
case MUSIC_TOGGLE_MODE.random:
|
||||||
playModeIcon = 'list-random'
|
playModeIcon = 'list-random'
|
||||||
break
|
break
|
||||||
case 'list':
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
playModeIcon = 'list-order'
|
playModeIcon = 'list-order'
|
||||||
break
|
break
|
||||||
case 'singleLoop':
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
playModeIcon = 'single-loop'
|
playModeIcon = 'single-loop'
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -23,7 +23,7 @@ import { playInfo as playInfoGetter } from './getter'
|
|||||||
import { play as lrcPlay, setLyric, pause as lrcPause, toggleTranslation as lrcToggleTranslation } from '@/utils/lyric'
|
import { play as lrcPlay, setLyric, pause as lrcPause, toggleTranslation as lrcToggleTranslation } from '@/utils/lyric'
|
||||||
import { showLyric, hideLyric, setLyric as lrcdSetLyric, toggleLock, setTheme, setLyricTextPosition, setAlpha, setTextSize } from '@/utils/lyricDesktop'
|
import { showLyric, hideLyric, setLyric as lrcdSetLyric, toggleLock, setTheme, setLyricTextPosition, setAlpha, setTextSize } from '@/utils/lyricDesktop'
|
||||||
import { action as listAction } from '@/store/modules/list'
|
import { action as listAction } from '@/store/modules/list'
|
||||||
import { LIST_ID_PLAY_LATER } from '@/config/constant'
|
import { LIST_ID_PLAY_LATER, MUSIC_TOGGLE_MODE } from '@/config/constant'
|
||||||
import { i18n } from '@/plugins/i18n'
|
import { i18n } from '@/plugins/i18n'
|
||||||
// import { defaultList } from '../list/getter'
|
// import { defaultList } from '../list/getter'
|
||||||
|
|
||||||
@ -630,15 +630,15 @@ export const playPrev = () => async(dispatch, getState) => {
|
|||||||
let nextIndex = currentIndex
|
let nextIndex = currentIndex
|
||||||
if (!playInfo.isTempPlay) {
|
if (!playInfo.isTempPlay) {
|
||||||
switch (common.setting.player.togglePlayMethod) {
|
switch (common.setting.player.togglePlayMethod) {
|
||||||
case 'random':
|
case MUSIC_TOGGLE_MODE.random:
|
||||||
nextIndex = getRandom(0, filteredList.length)
|
nextIndex = getRandom(0, filteredList.length)
|
||||||
break
|
break
|
||||||
case 'listLoop':
|
case MUSIC_TOGGLE_MODE.listLoop:
|
||||||
case 'list':
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
|
case MUSIC_TOGGLE_MODE.none:
|
||||||
nextIndex = currentIndex === 0 ? filteredList.length - 1 : currentIndex - 1
|
nextIndex = currentIndex === 0 ? filteredList.length - 1 : currentIndex - 1
|
||||||
break
|
break
|
||||||
case 'singleLoop':
|
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
nextIndex = -1
|
nextIndex = -1
|
||||||
return
|
return
|
||||||
@ -652,7 +652,7 @@ export const playPrev = () => async(dispatch, getState) => {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const playNext = () => async(dispatch, getState) => {
|
export const playNext = isAutoToggle => async(dispatch, getState) => {
|
||||||
const { player, common } = getState()
|
const { player, common } = getState()
|
||||||
if (player.tempPlayList.length) {
|
if (player.tempPlayList.length) {
|
||||||
const playMusicInfo = player.tempPlayList[0]
|
const playMusicInfo = player.tempPlayList[0]
|
||||||
@ -705,24 +705,32 @@ export const playNext = () => async(dispatch, getState) => {
|
|||||||
}
|
}
|
||||||
const currentIndex = listPlayIndex
|
const currentIndex = listPlayIndex
|
||||||
let nextIndex = currentIndex
|
let nextIndex = currentIndex
|
||||||
switch (common.setting.player.togglePlayMethod) {
|
let togglePlayMethod = common.setting.player.togglePlayMethod
|
||||||
case 'listLoop':
|
if (isAutoToggle !== true) {
|
||||||
|
switch (togglePlayMethod) {
|
||||||
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
|
case MUSIC_TOGGLE_MODE.none:
|
||||||
|
togglePlayMethod = MUSIC_TOGGLE_MODE.listLoop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (togglePlayMethod) {
|
||||||
|
case MUSIC_TOGGLE_MODE.listLoop:
|
||||||
nextIndex = currentIndex === filteredList.length - 1 ? 0 : currentIndex + 1
|
nextIndex = currentIndex === filteredList.length - 1 ? 0 : currentIndex + 1
|
||||||
break
|
break
|
||||||
case 'random':
|
case MUSIC_TOGGLE_MODE.random:
|
||||||
nextIndex = getRandom(0, filteredList.length)
|
nextIndex = getRandom(0, filteredList.length)
|
||||||
break
|
break
|
||||||
case 'list':
|
case MUSIC_TOGGLE_MODE.list:
|
||||||
nextIndex = currentIndex === filteredList.length - 1 ? -1 : currentIndex + 1
|
nextIndex = currentIndex === filteredList.length - 1 ? -1 : currentIndex + 1
|
||||||
break
|
break
|
||||||
case 'singleLoop':
|
case MUSIC_TOGGLE_MODE.singleLoop:
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
nextIndex = -1
|
nextIndex = -1
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(nextIndex)
|
|
||||||
if (nextIndex < 0) {
|
if (nextIndex < 0) {
|
||||||
dispatch(setStatus({ status: STATUS.stop, text: i18n.t('stopped') }))
|
dispatch(setStatus({ status: STATUS.stop, text: i18n.t('stopped') }))
|
||||||
lrcPause()
|
lrcPause()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user