Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Play Pause Sound in Java

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I want to do is very clear, just play sound and pause it. The problem is that I can't pause the music. When I click the pause button music keeps playing .I have been working on for 2 hours. I can't find the mistake; what am I doing wrong?
Edit:I am posting all code


 
Marshal
Posts: 75695
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show us a short bit of code where you are trying to pause the music. That is called an (link→)SSCCE.
Another link which tells you the same:- here.
 
Saloon Keeper
Posts: 9273
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is an AudioStream and an AudioPlayer? These are not part of standard Java.
 
Carey Brown
Saloon Keeper
Posts: 9273
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have several blocks of IF, IF, IF, IF that should be IF, ELSE-IF, ELSE-IF, ELSE-IF.
 
ali ak
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry.I know I shouldnt post all the code . But I cant find any solution for 2 days and .I thouht if I post all the code It might be helpfull someone who wants to test it .
 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know the API but there is something odd about starting the player with the audio stream and stopping it with the file input stream. Shouldn't you be calling stop() and passing in the audio stream and not the file input stream.
 
ali ak
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes my friend I have also realized that .But I havent changed until you point out. Because this was a small part of project that I found on the net .SoI thouht I must be like this way .But you are absolutely right.Thank you so muchh
 
Carey Brown
Saloon Keeper
Posts: 9273
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was the the only link I could find on playing MP3's with a pause capability. Probably using a different library than you a currently using: JLayer.
how-to-play-pause-a-mp3-file-using-the-javazoom-jlayer-library
 
ali ak
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tjank you for link
 
Carey Brown
Saloon Keeper
Posts: 9273
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was playing around with the JLayer library and I had to tweak it like this to get it to resume at the same place. It seems that event.getFrame() returns milliseconds and not frames. A "typical" MP3 has about 27ms per frame. If you could get access to the MP3's metadata you could verify this by looking at the sampling rate and samples per frame. Also, getFrame() does not return the absolute position in the MP3 but the position relative to the start point, which is different if you've already done a pause-resume, hence the increment (+=).

 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic