mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-06 20:10:12 +02:00
reorganize
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ import type { RefObject } from 'react';
|
||||
import { useImperativeHandle, useRef, useState } from 'react';
|
||||
import ReactPlayer from 'react-player';
|
||||
|
||||
import { AudioPlayer } from '/@/renderer/components/audio-player/types';
|
||||
import { AudioPlayer } from '/@/renderer/features/player/audio-player/types';
|
||||
import { PlayerStatus } from '/@/shared/types/types';
|
||||
|
||||
export interface OnProgressProps {
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
|
||||
import {
|
||||
createPlayerEvents,
|
||||
PlayerEventsCallbacks,
|
||||
} from '/@/renderer/components/audio-player/listener/player-events';
|
||||
} from '/@/renderer/features/player/audio-player/listener/player-events';
|
||||
|
||||
export function usePlayerEvents(callbacks: PlayerEventsCallbacks, deps: React.DependencyList) {
|
||||
useEffect(() => {
|
||||
+8
-5
@@ -6,7 +6,7 @@ import { OnProgressProps } from 'react-player/base';
|
||||
|
||||
import { WebPlayerEngine, WebPlayerEngineHandle } from './engine/web-player-engine';
|
||||
|
||||
import { usePlayerEvents } from '/@/renderer/components/audio-player/listener/use-player-events';
|
||||
import { usePlayerEvents } from '/@/renderer/features/player/audio-player/listener/use-player-events';
|
||||
import {
|
||||
usePlayerActions,
|
||||
usePlayerData,
|
||||
@@ -19,7 +19,7 @@ import { PlayerStatus, PlayerStyle } from '/@/shared/types/types';
|
||||
const PLAY_PAUSE_FADE_DURATION = 300;
|
||||
const PLAY_PAUSE_FADE_INTERVAL = 10;
|
||||
|
||||
export function AudiolingWebPlayer() {
|
||||
export function WebPlayer() {
|
||||
const playerRef = useRef<WebPlayerEngineHandle>(null);
|
||||
const { player, player1, player2 } = usePlayerData();
|
||||
const { mediaAutoNext, setProgress } = usePlayerActions();
|
||||
@@ -178,21 +178,24 @@ export function AudiolingWebPlayer() {
|
||||
|
||||
usePlayerEvents(
|
||||
{
|
||||
onPlayerSeekToTimestamp: (timestamp) => {
|
||||
onPlayerSeekToTimestamp: (properties) => {
|
||||
const timestamp = properties.timestamp;
|
||||
if (player.playerNum === 1) {
|
||||
playerRef.current?.player1()?.ref?.seekTo(timestamp);
|
||||
} else {
|
||||
playerRef.current?.player2()?.ref?.seekTo(timestamp);
|
||||
}
|
||||
},
|
||||
onPlayerStatus: async (status) => {
|
||||
onPlayerStatus: async (properties) => {
|
||||
const status = properties.status;
|
||||
if (status === PlayerStatus.PAUSED) {
|
||||
fadeAndSetStatus(volume, 0, PLAY_PAUSE_FADE_DURATION, PlayerStatus.PAUSED);
|
||||
} else if (status === PlayerStatus.PLAYING) {
|
||||
fadeAndSetStatus(0, volume, PLAY_PAUSE_FADE_DURATION, PlayerStatus.PLAYING);
|
||||
}
|
||||
},
|
||||
onPlayerVolume: (volume) => {
|
||||
onPlayerVolume: (properties) => {
|
||||
const volume = properties.volume;
|
||||
playerRef.current?.setVolume(volume);
|
||||
},
|
||||
},
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import { createContext, useCallback, useMemo } from 'react';
|
||||
import { Song } from 'src/main/features/core/lyrics/netease';
|
||||
|
||||
import { AddToQueueType } from '/@/renderer/store';
|
||||
import { LibraryItem, QueueSong } from '/@/shared/types/domain-types';
|
||||
import { LibraryItem, QueueSong, Song } from '/@/shared/types/domain-types';
|
||||
|
||||
interface PlayerContext {
|
||||
addToQueueByData: (data: Song[], type: AddToQueueType) => void;
|
||||
Reference in New Issue
Block a user