Skip to content

Commit

Permalink
fix: remove
Browse files Browse the repository at this point in the history
  • Loading branch information
tingyuan committed Sep 21, 2024
1 parent ec97547 commit 238d0f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/hooks/useBackgroundTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TaskMap = {
KeepMusicPlay: () => {},
test: () => null,
CheckLivingUps: () => null,
KeepVideoPlay: () => null,
}

type TaskMapType = typeof TaskMap
Expand Down
18 changes: 10 additions & 8 deletions src/routes/Music/Player.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useFocusEffect } from '@react-navigation/native'
import { Icon, Slider, Text } from '@rneui/themed'
import clsx from 'clsx'
import {
Expand Down Expand Up @@ -67,14 +68,7 @@ function PlayerBar(props: { url?: string; time?: number; error?: boolean }) {
nextSong: songs[index + 1] ?? null,
}
}, [playingSong, get$musicList])
// useBackgroundTask(
// 'KeepMusicPlay',
// useMemoizedFn(() => {
// soundRef.current?.getStatusAsync().then((status) => {
// handlePlayStatusChange(status)
// })
// }),
// )

const handlePlayStatusChange = useMemoizedFn(
React.useMemo(() => {
return (status: AVPlaybackStatus) => {
Expand Down Expand Up @@ -130,6 +124,14 @@ function PlayerBar(props: { url?: string; time?: number; error?: boolean }) {
}
}, [props.url])

useFocusEffect(
React.useCallback(() => {
return () => {
soundRef.current?.unloadAsync()
}
}, []),
)

const isDark = useIsDark()
if (!playingSong) {
return null
Expand Down
23 changes: 1 addition & 22 deletions src/routes/Play/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { useAppStateChange } from '../../hooks/useAppState'
import { useStore } from '../../store'
import { parseDuration, parseImgUrl, showToast } from '../../utils'
import { INJECTED_JAVASCRIPT } from './inject-play'

const PlayUrl = 'https://www.bilibili.com/blackboard/html5mobileplayer.html'

export default React.memo(Player)
Expand Down Expand Up @@ -93,28 +94,6 @@ function Player(props: { currentPage: number; onPlayEnded: () => void }) {
}
if (currentAppState !== 'active') {
KeepAwake.deactivateKeepAwake('PLAY')
webviewRef.current?.requestFocus()
webviewRef.current?.postMessage('dsfs')
setTimeout(() => {
webviewRef.current?.requestFocus()
webviewRef.current?.postMessage('dsfs')
webviewRef.current?.injectJavaScript(`
(function() {
const aa = document.getElementById('play-rate-button')
if (aa ) {
aa.style.backgroundColor = 'red';
}
})(); true;
`)
}, 1000)
webviewRef.current?.injectJavaScript(`
(function() {
const video = document.querySelector('video');
if (video) {
video.play()
}
})(); true;
`)
}
})

Expand Down

0 comments on commit 238d0f1

Please sign in to comment.