暂停在java中的mp3 [英] pausing mp3 in java

查看:452
本文介绍了暂停在java中的mp3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在在其中,我需要播放背景MP3声音的项目。我设法做使用Jlayer库和一块code的发现这里

I'm currently working on a project in which i need to play a background mp3 sound. I managed to do that using the Jlayer library and a piece of code found here

不过,我需要一些更多的功能添加到这个code,如循环播放和暂停。结果
循环功能是相当容易实现,但我已经花了几个小时寻找一种方式,暂停和恢复的MP3文件。

However, I needed to add some more features to this code, such as loop playing and pause.
The loop function was fairly easy to implement, but i've spent hours looking for a way to pause and resume mp3 files.

我的猜测一直在使用播放(INT帧)方法Player类,使用为getPosition()方法和MP3总帧数,但我不能设法得到的总帧数。

My guess would have been to use the play(int frames) method in the Player class, using the getPosition() method and the mp3 total frame number, but i can't manage to get the total frame number.

任何线索?我只是需要这种暂停/恢复方法,所以如果你知道与此不同的一种方式,随意张贴

Any clue ? I just need this pause/resume method, so if you know one way different from this, feel free to post

我也一直在尝试一些东西与BasicPlayer库(链接这里) ,但我最后总是试图读取任何MP3文件时,取得javax.sound.sampled.UnsupportedAudioFileException

i've also been trying some stuff with the BasicPlayer library (link here), but i always end up getting javax.sound.sampled.UnsupportedAudioFileException when trying to read any mp3 file

推荐答案

您不能做到这一点的默认播放器的实现。

You can't do that with the Default Player implementation.

您需要实现流类和读取数据的哪些类DataSourceLine。
这是一个有点辛苦,但它是可能的。我2年前做的,如果我发现我的code我邮寄给你。

You need to implement the stream classes and read data which those DataSourceLine classes. It's a bit hard work, but it's possible. I did it 2 years ago, if I found my code I post it to you.

这篇关于暂停在java中的mp3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆