Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【优化】切换歌曲后第一时间的播放进度会被上一首数据污染 #16

Open
Theoneee opened this issue Jun 17, 2022 · 3 comments
Labels

Comments

@Theoneee
Copy link
Contributor

现在当前播放的数据是只有一个实例:

private PlayingMusic mCurrentPlay = new PlayingMusic("00:00", "00:00");

但是当切换歌曲时,只是更换了部分播放数据:

   public void setChangingPlayingMusic(boolean changingPlayingMusic) {
        mIsChangingPlayingMusic = changingPlayingMusic;
        if (mIsChangingPlayingMusic) {
            ...
            mCurrentPlay.setBaseInfo(mPlayingInfoManager.getMusicAlbum(), getCurrentPlayingMusic());
           ....
        }
    }

    public void setBaseInfo(B musicAlbum, M music) {
        //要用当前实际播放的列表,因为不同模式存在不同的播放列表
        this.title = music.getTitle();
        this.summary = musicAlbum.getSummary();
        this.albumId = musicAlbum.getAlbumId();
        this.musicId = music.getMusicId();
        this.img = music.getCoverImg();
        this.artist = (A) music.getArtist();
        this.music = music;
    }

这个时候的播放进度和时间是没有被重置的,分发当前播放音乐消息时会把上一首的播放数据也带过去,造成数据污染,
建议在更换歌曲时重置一下播放进度和时间:

   public void setChangingPlayingMusic(boolean changingPlayingMusic) {
        mIsChangingPlayingMusic = changingPlayingMusic;
        if (mIsChangingPlayingMusic) {
             // 重置播放时间和进度数据
            mCurrentPlay.setNowTime("00:00");
            mCurrentPlay.setAllTime("00:00");
            mCurrentPlay.setPlayerPosition(0);
            mCurrentPlay.setDuration(0);
            mCurrentPlay.setBaseInfo(mPlayingInfoManager.getMusicAlbum(), getCurrentPlayingMusic());
           ....
        }
    }
@KunMinX
Copy link
Owner

KunMinX commented Jun 17, 2022

感谢反馈

@KunMinX KunMinX added the 精华 label Jun 17, 2022
@KunMinX
Copy link
Owner

KunMinX commented Jun 17, 2022

开源非吾一人战斗,我们希望每位有效贡献者皆可出现在 contributions 名单。
本 issue 具实用性,可否邀您 fork & pull request,我看到则予以处理。

@Theoneee
Copy link
Contributor Author

开源非吾一人战斗,我们希望每位有效贡献者皆可出现在 contributions 名单。 本 issue 具实用性,可否邀您 fork & pull request,我看到则予以处理。

已PR,格式化了一下代码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants