Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Looping MP3  (Read 1120 times)
0 Members and 1 Guest are viewing this topic.
Offline Luminem

Senior Newbie





« Posted 2012-12-18 21:27:13 »

Hey guys i'm new on this forum, so i'm sorry if this is the wrong place to post this. Wink My question is, how can i loop a MP3? Actually i'm using JLayer and i can loop it twice, only twice, and after the music stops but not the game. What happens to me?

Simply Perfect
Offline davedes
« Reply #1 - Posted 2012-12-18 21:46:40 »

MP3 includes a short amount of silence at the start -- use OGG or WAV for loops.

Offline Luminem

Senior Newbie





« Reply #2 - Posted 2012-12-18 22:06:00 »

But the music stops complety. will the music stop complety if I use ogg?  Because I don't want to use WAV files they are too heavy.

Simply Perfect
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #3 - Posted 2012-12-18 22:07:05 »

The music will still stop if u use an ogg, I know there is a way to progam this, but sorry Im also a newb lol idk how:(

Offline Sammidysam
« Reply #4 - Posted 2012-12-18 22:13:39 »

But the music stops complety. will the music stop complety if I use ogg?  Because I don't want to use WAV files they are too heavy.

I'm not really sure about the library that you are using, but most likely you can do this in two ways:

1. Calculate milliseconds of audio and call the play method of the song when a timer reaches that millisecond value.
2. If your library has a boolean for all songs called finished, you can just check if finished == true in your game loop and if it is true then call the play method of the song.

The 2nd option is more efficient.

Let me know if either of these don't make sense, I can elaborate on them if necessary.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #5 - Posted 2012-12-18 22:19:28 »

If you are using JLayer, they have a Listener in the API. If you override that, you should be able to tell when the music stops and start it all over from the beginning.

Or you can just check out TinySound if you want functionality like this for ogg, mp3's, and the like. It works pretty well if you are just trying to get music working.

Offline Sammidysam
« Reply #6 - Posted 2012-12-18 22:20:21 »

If you are using JLayer, they have a Listener in the API. If you override that, you should be able to tell when the music stops and start it all over from the beginning.

Or you can just check out TinySound if you want functionality like this for ogg, mp3's, and the like. It works pretty well if you are just trying to get music working.

I recommend TinySound!  I used it in my first game and it worked really well.
Offline Luminem

Senior Newbie





« Reply #7 - Posted 2012-12-19 13:05:58 »

Okay Wink TinySound is pretty good for me Cheesy and here the big question. a post ago i said WAV was very heavy... So now my question is: Really? Is it too heavy for a background music loop?  Huh

Simply Perfect
Online nsigma
« Reply #8 - Posted 2012-12-19 14:37:22 »

Okay Wink TinySound is pretty good for me Cheesy and here the big question. a post ago i said WAV was very heavy... So now my question is: Really? Is it too heavy for a background music loop?  Huh

Odd question!  Don't confuse the way you distribute sounds with the way you play them.  You can ship them compressed, and uncompress them into memory at runtime (as long as they're not too big) which will give you better seamless looping, or stream them and uncompress on the fly.  It looks like TinySound uses the standard JavaSound stream support, which means it can either stream or load WAVs by default.  However, if you put JARs on the classpath that are JavaSound service providers, it should be able to load other formats.  There is OGG support in the TinySound repo, and it should be able to load MP3 in the same way by putting the right JLayer JAR on your classpath.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Sammidysam
« Reply #9 - Posted 2012-12-20 00:51:48 »

Well just in terms of space WAV is huge and OGG is really low, so I suggest OGG since it'll make your game download faster.  Thus, your players will have more time to play.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (36 views)
2014-12-15 00:26:44

Mr.CodeIt (29 views)
2014-12-14 10:50:38

BurntPizza (61 views)
2014-12-09 13:41:13

BurntPizza (98 views)
2014-12-07 19:46:31

JscottyBieshaar (58 views)
2014-12-05 03:39:02

SHC (74 views)
2014-12-03 07:27:13

CopyableCougar4 (76 views)
2014-11-29 12:32:03

toopeicgaming1999 (137 views)
2014-11-26 06:22:04

toopeicgaming1999 (127 views)
2014-11-26 06:20:36

toopeicgaming1999 (37 views)
2014-11-26 06:20:08
Resources for WIP games
by kpars
2014-12-18 01:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 13:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 13:36:02

List of Learning Resources
by Longor1996
2014-08-16 01:40:00

List of Learning Resources
by SilverTiger
2014-08-05 10:33:27

Resources for WIP games
by CogWheelz
2014-08-01 07:20:17

Resources for WIP games
by CogWheelz
2014-08-01 07:19:50

List of Learning Resources
by SilverTiger
2014-07-31 07:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!