My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.badlogic.gamedev.samples;

import javax.microedition.khronos.opengles.GL10;

import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;

import com.badlogic.gamedev.tools.GameActivity;
import com.badlogic.gamedev.tools.GameListener;

public class MusicSample extends GameActivity implements GameListener
{
MediaPlayer mediaPlayer;

public void onCreate( Bundle bundle )
{
super.onCreate( bundle );
setGameListener( this );
}

@Override
protected void onPause( )
{
super.onPause();
mediaPlayer.release();
}

@Override
public void setup(GameActivity activity, GL10 gl)
{
mediaPlayer = new MediaPlayer();
try
{
AssetFileDescriptor descriptor = getAssets().openFd( "8.12.mp3" );
mediaPlayer.setDataSource( descriptor.getFileDescriptor() );
mediaPlayer.prepare();
mediaPlayer.start();
}
catch( Exception ex )
{
Log.d( "Sound Sample", "couldn't load music '8.12.mp3'" );
throw new RuntimeException( ex );
}
}

@Override
public void mainLoopIteration(GameActivity activity, GL10 gl)
{

}
}

Change log

r44 by quantumgame on Jan 11, 2010   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

r30 by quantumgame on Jan 10, 2010   Diff
[No log message]
All revisions of this file

File info

Size: 1134 bytes, 53 lines
Powered by Google Project Hosting