1. Download our Official Android App: Forums for Android!

Apps soundpool issue

Discussion in 'Android Development' started by prabh0023, Apr 29, 2016.

  1. prabh0023

    prabh0023 Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    1
    Joined:
    Apr 29, 2016

    Apr 29, 2016
    1
    0
    15
    Male
    Hello all,

    So, this is what I do.

    In core class

    Code (Text):
    1.  
    2. package com.mygdx.game;
    3.  
    4. import com.badlogic.gdx.
    5. ApplicationAdapter;
    6. import com.badlogic.gdx.Gdx;
    7. import com.badlogic.gdx.audio.Sound;
    8. import com.badlogic.gdx.graphics.GL20;
    9. import com.badlogic.gdx.graphics.Texture;
    10. import com.badlogic.gdx.graphics.g2d.BitmapFont;
    11. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
    12.  
    13. public class MyGdxGame extends ApplicationAdapter {
    14.   SpriteBatch batch;
    15.   Texture img;
    16.  
    17.   Sound rocketLoop;
    18.  
    19.   @Override
    20.   public void create () {
    21.     batch = new SpriteBatch();
    22.     img = new Texture("badlogic.jpg");
    23.     rocketLoop = Gdx.audio.newSound(Gdx.files.internal("rocket.ogg"));
    24.     rocketLoop.loop();
    25.   }
    26.  
    27.   @Override
    28.   public void render () {
    29.     Gdx.gl.glClearColor(1, 0, 0, 1);
    30.     Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    31.     batch.begin();
    32.    
    33.     batch.draw(img, 0, 0);
    34.     batch.end();
    35.   }
    36. }
    37.  
    After debugging I've traced it down to Soundpool.load().


    I get an error, and nothing plays. But, with "Music" it plays.
    Please help! It works fine with desktop projects. I can't find shit on google.

    Thanks
     

    Advertisement

Share This Page

Loading...