Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound clip plays only once in Java backend #48

Open
guillerodriguez opened this issue Sep 25, 2017 · 0 comments
Open

Sound clip plays only once in Java backend #48

guillerodriguez opened this issue Sep 25, 2017 · 0 comments

Comments

@guillerodriguez
Copy link
Contributor

In some configurations, sound clips can only be played once.

  • My environment: OpenJDK 1.8.0_141 on Ubuntu 14.04.5.
  • IcedTea/PulseAudio sound provider (default for OpenJDK in Ubuntu)
  • PlayN 2.1-SNAPSHOT

Sample code:

public class SoundTest extends SceneGame {
  boolean playAgain = true;
  playn.core.Sound sound;

  public SoundTest (final Platform plat) {
    super(plat, 33); // update our "simulation" 33ms (30 times per second)

    // create and add background image layer
    Image bgImage = plat.assets().getImage("images/bg.png");
    ImageLayer bgLayer = new ImageLayer(bgImage);
    // scale the background to fill the screen
    bgLayer.setSize(plat.graphics().viewSize);
    rootLayer.add(bgLayer);
    
    sound = plat.assets().getSound("sounds/drop");
    sound.play();
  }
  
  public void update(Clock t) {
    if (playAgain && plat.tick() > 5000) {
      sound.play();
      playAgain = false;
    }
  }
}

This may be related to the following:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant