背景音乐长度和速度

发布于 2024-12-27 16:40:13 字数 216 浏览 0 评论 0原文

对于我的 Android 应用程序,我想要背景音乐。它不必跨越活动,因此服务并不重要。

Soundpool 似乎在大约 6 秒后停止播放 .ogg 或 .mp3 MediaPlayer 无法更改音乐的速度(速率)

我想做的是允许用户更改正在播放的背景音乐的速度。 SoundPool 似乎可以做到这一点,但很难说,因为它只播放几秒钟。

对于如何执行此操作有什么建议吗?

For my Android app I would like background music. It doesn't have to go across activities so services do not matter.

Soundpool seems to stop playing the .ogg or .mp3 after about 6 seconds
MediaPlayer doesn't have the ability to change the speed (rate) of the music

What I would like to do is to allow the user to change the speed of the background music as it is playing. It would seem like SoundPool can do this but its hard to tell since it only plays for a few seconds.

Any suggestions for how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的年少不轻狂 2025-01-03 16:40:13

SoundPool 对于 wav 文件来说很糟糕,对于 mp3 我没有问题...

    public final int play (int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate) 

浮动速率 - 值 0.5 意味着以半速播放,可以是 0.5-2...我认为你应该使用 SoundPool... 作为对我来说,我很欣赏 Mediaplayer...

SoundPool is bad with wav files, with mp3 I didn't have problems...

    public final int play (int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate) 

float rate - value of 0.5 means playback at half speed, can be 0.5-2.... I think you ought to use SoundPool... As for me, I appreciate Mediaplayer...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文