package com.google.sprint1;

import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.media.SoundPool.OnLoadCompleteListener;
import android.util.Log;

public class Sound {
	
	static boolean loaded = false;
	
	public static int[] loadSound(Context context){
		
		SoundPool soundPool;
		soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
		int soundIds[] = new int[10];
		soundIds[0] = soundPool.load(context, R.raw.ping, 1);
		
		soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener(){

			@Override
			public void onLoadComplete(SoundPool soundPool, int sampleId,
					int status) {
				loaded = true;
				
			}
			
		});
		
		Log.e("Test", "soundID before = " + soundIds[0]);
		Log.e("Test", "Loaded = " + loaded);
		
		return soundIds;
		
		}
	
	public static void playBackgroundMusic(Context context){
	
	MediaPlayer backgroundMusic;
	backgroundMusic = MediaPlayer.create(context, R.raw.good);
	
	backgroundMusic.setLooping(true);
	backgroundMusic.setVolume(10.0f, 3.0f);
	backgroundMusic.start();
	
	}
	
	public static void playsoundEffect(int soundID){
		
		
		//should use soundpool insteed of mediaplayer
		/*SoundPool sp;
		
		sp = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
		
		int soundIds[] = new int[10];
		soundIds[0] = sp.load(context, R.raw.ping, 1);
		
		sp.play(soundIds[0], 1, 1, 1, 0, (float) 1.0);*/
		/*
		MediaPlayer backgroundMusic;
		backgroundMusic = MediaPlayer.create(context, R.raw.ping);
		
		backgroundMusic.setLooping(false);
		backgroundMusic.setVolume(10.0f, 3.0f);
		backgroundMusic.start();
		*/
		
		SoundPool soundPool;
		soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
		
		Log.e("Test", "soundID play = " + soundID);
		
		soundPool.play(soundID, 1, 1, 1, 0, 1.0f);
		
	}

}

@@ -159,702 +159,31 @@
 ol;%0A
-import android.media.SoundPool.OnLoadCompleteListener;%0Aimport android.util.Log;%0A%0Apublic class Sound %7B%0A%09%0A%09static boolean loaded = false;%0A%09%0A%09public static int%5B%5D loadSound(Context context)%7B%0A%09%09%0A%09%09SoundPool soundPool;%0A%09%09soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);%0A%09%09int soundIds%5B%5D = new int%5B10%5D;%0A%09%09soundIds%5B0%5D = soundPool.load(context, R.raw.ping, 1);%0A%09%09%0A%09%09soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener()%7B%0A%0A%09%09%09@Override%0A%09%09%09public void onLoadComplete(SoundPool soundPool, int sampleId,%0A%09%09%09%09%09int status) %7B%0A%09%09%09%09loaded = true;%0A%09%09%09%09%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D);%0A%09%09%0A%09%09Log.e(%22Test%22, %22soundID before = %22 + soundIds%5B0%5D);%0A%09%09Log.e(%22Test%22, %22Loaded = %22 + loaded);%0A%09%09%0A%09%09return soundIds;%0A%09%09%0A%09%09%7D
+%0Apublic class Sound %7B%0A%09
 %0A%09%0A%09
@@ -482,63 +482,68 @@
 ect(
-int soundID)%7B%0A%09%09%0A%09%09%0A%09%09//should use s
+Context context)%7B%0A%09%09%0A%09%09%0A%09%09//Vill anvnda S
 ound
-p
+P
 ool i
-n
 st
-eed of
+llet fr
  med
@@ -767,18 +767,16 @@
 0);*/%0A%09%09
-/*
 %0A%09%09Media
@@ -973,201 +973,8 @@
 ();%0A
-%09%09*/%0A%09%09%0A%09%09SoundPool soundPool;%0A%09%09soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);%0A%09%09%0A%09%09Log.e(%22Test%22, %22soundID play = %22 + soundID);%0A%09%09%0A%09%09soundPool.play(soundID, 1, 1, 1, 0, 1.0f);%0A%09%09%0A
 %09%7D%0A%0A

Revert "load class"