[Desktop] Music getPosition() not accurate on desktop for MP3s
See original GitHub issueMusic.getPosition()
lags behind the actual sound position on desktop. Using the code below, the sound is noticeably out of sync after just a few seconds. Everything works as expected on Android and iOS.
Using the latest GDX release (1.9.9).
package com.bnich.soundtest;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.GL20;
public class Game extends ApplicationAdapter {
Music music;
@Override
public void create() {
// https://www.dropbox.com/s/foyn8lps7rihwkw/60bpm.mp3?dl=0
music = Gdx.audio.newMusic(Gdx.files.internal("60bpm.mp3"));
music.play();
}
@Override
public void render() {
float beat = music.getPosition() % 1;
if (beat < 0.05f)
Gdx.gl.glClearColor(1, 1, 1, 1);
else
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
MP3: a way to get position in milliseconds for any given byte ...
I know the total length of the stream in bytes and seconds, and then just "convert" the byteposition to the timescale. It might...
Read more >Problems playing wav's and mp3's on my windows 10 pc
Hi, if you use windows media player it can be a codec issue. I would try to use another media player for testing....
Read more >com.badlogic.gdx.audio.Music.play java code examples
How to use. play. method. in. com.badlogic.gdx.audio.Music ... @Override public void create () { // copy an internal mp3 to the external storage...
Read more >mp3 music player application development using android
The project could not be going smoothly without the help of these people. First of all, I would like to express my appreciation...
Read more >How can I play an MP3 from my desktop w/o opening an app?
Previously, in icon view, I was able to play audio MP3 files directly from the desktop - without them opening iTunes or QuickTime....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you prefix the title with [Desktop]? Thanks
@thebnich thank you, i replaced it. It’s even better, it has different sounds on note / quarter note 😃