mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 06:52:09 +08:00
修复非循环模式下播放结束后的状态显示问题及无法重新播放的问题(#104)
This commit is contained in:
parent
f7533c3f9b
commit
1444dd1b70
@ -10,6 +10,7 @@
|
||||
- 修复wy源搜索某些歌曲时第一页之后的歌曲无法加载的问题
|
||||
- 每次启动时过滤无效的歌曲
|
||||
- 修复换源失败时的处理问题
|
||||
- 修复非循环模式下播放结束后的状态显示问题及无法重新播放的问题(#104)
|
||||
|
||||
### 变更
|
||||
|
||||
|
@ -33,3 +33,4 @@ global.playInfo = {
|
||||
|
||||
global.isEnableSyncLog = false
|
||||
|
||||
global.playerTrackId = ''
|
||||
|
@ -219,6 +219,7 @@
|
||||
"source_real_tx": "Tencent",
|
||||
"source_real_wy": "Netease",
|
||||
"stop": "Stop",
|
||||
"stopped": "Stopped",
|
||||
"storage_permission_tip_disagree": "User Disagree",
|
||||
"storage_permission_tip_disagree_ask_again": "This feature cannot be used because you have permanently denied LX access to the phone storage.\nIf you want to continue, you need to go to System Permission Management Set Luo Xue’s storage permission to allow.",
|
||||
"storage_permission_tip_request": "To use this function, you need to allow LX to access the phone storage. Do you agree and continue?",
|
||||
|
@ -221,6 +221,7 @@
|
||||
"source_real_tx": "企鹅音乐",
|
||||
"source_real_wy": "网易音乐",
|
||||
"stop": "停止",
|
||||
"stopped": "已停止",
|
||||
"storage_permission_tip_disagree": "你个骗纸,刚刚问你,你都说同意的,最后又拒绝,哼 🥺",
|
||||
"storage_permission_tip_disagree_ask_again": "此功能无法使用,因为你已经永久拒绝洛雪访问手机存储😫。\n若想继续,你需要去👉系统权限管理👈将洛雪的存储权限设置为允许",
|
||||
"storage_permission_tip_request": "使用此功能需要允许洛雪访问手机存储,是否同意并继续?",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import TrackPlayer, { State as TPState, Event as TPEvent } from 'react-native-track-player'
|
||||
import { getStore } from '@/store'
|
||||
import { action as playerAction, STATUS } from '@/store/modules/player'
|
||||
import { isTempTrack } from './utils'
|
||||
import { isTempId, isEmpty } from './utils'
|
||||
import { play as lrcPlay, pause as lrcPause } from '@/utils/lyric'
|
||||
import { exitApp } from '@/utils/common'
|
||||
import { getCurrentTrackId, getCurrentTrack, delayUpdateMusicInfo, buildTrack } from './playList'
|
||||
@ -13,10 +13,8 @@ let isInitialized = false
|
||||
let retryTrack = null
|
||||
let retryGetUrlId = null
|
||||
let retryGetUrlNum = 0
|
||||
let trackId = ''
|
||||
let errorTime = 0
|
||||
// let prevDuration = 0
|
||||
const tempIdRxp = /\/\/default$|\/\/default\/\/restorePlay$/
|
||||
// let isPlaying = false
|
||||
|
||||
// 销毁播放器并退出
|
||||
@ -107,11 +105,11 @@ export default async() => {
|
||||
|
||||
TrackPlayer.addEventListener(TPEvent.PlaybackState, async info => {
|
||||
const state = store.getState()
|
||||
// console.log('playback-state', TPState[info.state])
|
||||
console.log('playback-state', TPState[info.state])
|
||||
|
||||
// console.log((await getCurrentTrack())?.id)
|
||||
if (state.player.isGettingUrl) return
|
||||
if (trackId && tempIdRxp.test(trackId)) return
|
||||
if (isTempId()) return
|
||||
let currentIsPlaying = false
|
||||
|
||||
switch (info.state) {
|
||||
@ -182,8 +180,8 @@ export default async() => {
|
||||
// console.log('nextTrack====>', info)
|
||||
if (global.isPlayedExit) return handleExitApp()
|
||||
|
||||
trackId = await getCurrentTrackId()
|
||||
if (trackId && isTempTrack(trackId)) {
|
||||
global.playerTrackId = await getCurrentTrackId()
|
||||
if (isEmpty()) {
|
||||
console.log('====TEMP PAUSE====')
|
||||
TrackPlayer.pause()
|
||||
if (retryTrack) {
|
||||
|
@ -5,7 +5,10 @@ import { playMusic as handlePlayMusic } from './playList'
|
||||
|
||||
export { useProgress } from './hook'
|
||||
|
||||
export const isTempTrack = trackId => /\/\/default$/.test(trackId)
|
||||
const emptyIdRxp = /\/\/default$/
|
||||
const tempIdRxp = /\/\/default$|\/\/default\/\/restorePlay$/
|
||||
export const isEmpty = (trackId = global.playerTrackId) => emptyIdRxp.test(trackId)
|
||||
export const isTempId = (trackId = global.playerTrackId) => tempIdRxp.test(trackId)
|
||||
|
||||
// export const replacePlayTrack = async(newTrack, oldTrack) => {
|
||||
// console.log('replaceTrack')
|
||||
|
@ -13,7 +13,7 @@ export default memo(() => {
|
||||
const status = useMemo(() => playStatus == STATUS.playing
|
||||
? text
|
||||
: (
|
||||
(playStatus == STATUS.pause || playStatus == STATUS.stop) && text
|
||||
playStatus == STATUS.pause && text
|
||||
? text
|
||||
: statusText
|
||||
), [playStatus, statusText, text])
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
seekTo,
|
||||
resetPlay,
|
||||
getPosition,
|
||||
isEmpty,
|
||||
destroy as msDestroy,
|
||||
} from '@/plugins/player/utils'
|
||||
import {
|
||||
@ -23,6 +24,7 @@ import { play as lrcPlay, setLyric, pause as lrcPause, toggleTranslation as lrcT
|
||||
import { showLyric, hideLyric, setLyric as lrcdSetLyric, toggleLock, setTheme, setLyricTextPosition, setAlpha, setTextSize } from '@/utils/lyricDesktop'
|
||||
import { action as listAction } from '@/store/modules/list'
|
||||
import { LIST_ID_PLAY_LATER } from '@/config/constant'
|
||||
import { i18n } from '@/plugins/i18n'
|
||||
// import { defaultList } from '../list/getter'
|
||||
|
||||
export const TYPES = {
|
||||
@ -441,7 +443,7 @@ export const playMusic = playMusicInfo => async(dispatch, getState) => {
|
||||
if (playMusicInfo === undefined) {
|
||||
if (player.isGettingUrl || !_playMusicInfo) return
|
||||
// console.log(player.isGettingUrl, _playMusicInfo)
|
||||
if (/\/\/restorePlay$/.test(playMusicId) || player.status == STATUS.none) {
|
||||
if (/\/\/restorePlay$/.test(playMusicId) || player.status == STATUS.none || isEmpty()) {
|
||||
handlePlayMusic({
|
||||
getState,
|
||||
dispatch,
|
||||
@ -717,9 +719,15 @@ export const playNext = () => async(dispatch, getState) => {
|
||||
break
|
||||
default:
|
||||
nextIndex = -1
|
||||
return
|
||||
break
|
||||
}
|
||||
|
||||
console.log(nextIndex)
|
||||
if (nextIndex < 0) {
|
||||
dispatch(setStatus({ status: STATUS.stop, text: i18n.t('stopped') }))
|
||||
lrcPause()
|
||||
return
|
||||
}
|
||||
if (nextIndex < 0) return
|
||||
|
||||
dispatch(playMusic({
|
||||
musicInfo: filteredList[nextIndex],
|
||||
|
Loading…
x
Reference in New Issue
Block a user