Code Monkey home page Code Monkey logo

Comments (3)

lovegaoshi avatar lovegaoshi commented on June 15, 2024

pr welcome

eg. https://github.com/lovegaoshi/azusa-player/blob/d689d93e4213872eabe8d37de8f0311b425fbdcd/src/components/App/App.tsx#L42

from azusa-player.

Takenforgranted avatar Takenforgranted commented on June 15, 2024

pr welcome

eg. https://github.com/lovegaoshi/azusa-player/blob/d689d93e4213872eabe8d37de8f0311b425fbdcd/src/components/App/App.tsx#L42

忙,没空改,给个样子吧要是我下午晚上事情多顾不上你就自己改改

// 当用户按下空格键时触发的事件处理函数
useHotkeys('space', () => {
    // 如果当前音频实例为空,直接返回
    if (currentAudioInst === null) return;

    // 如果音频处于暂停状态,则播放;如果正在播放,则暂停
    if (currentAudioInst.paused)
        // @ts-expect-error
        document.getElementsByClassName('music-player-audio')[0].play();
    else
        // @ts-expect-error
        document.getElementsByClassName('music-player-audio')[0].pause();
});

// 当用户按下PageDown键时触发的事件处理函数,用于播放下一首音频
// @ts-expect-error
useHotkeys('arrowdown', () => window.musicplayer.onPlayNextAudio());

// 当用户按下PageUp键时触发的事件处理函数,用于播放上一首音频
// @ts-expect-error
useHotkeys('arrowup', () => window.musicplayer.onPlayPrevAudio());

// 当用户按下右方向键时触发的事件处理函数,用于音频快进5秒
useHotkeys('arrowright', () => {
    if (currentAudioInst === null) return;
    currentAudioInst.currentTime += 5;
});

// 当用户按下左方向键时触发的事件处理函数,用于音频后退5秒
useHotkeys('arrowleft', () => {
    if (currentAudioInst === null) return;
    currentAudioInst.currentTime -= 5;
});

// 当currentAudio的名称发生变化时,更新页面标题
useEffect(() => {
    // 如果currentAudio的名称不存在,直接返回
    if (!currentAudio?.name) return;

    // 更新页面标题为当前音频的名称和应用标题的组合
    document.title = `${currentAudio.name} - ${appTitle}`;
}, [currentAudio?.name]);

from azusa-player.

Takenforgranted avatar Takenforgranted commented on June 15, 2024

@lovegaoshi 不得不说,你和我的作息tmd正好相反啊

from azusa-player.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.