我有你的位置的GridView和我在的onCreate做的情況下,那麼,錯誤試圖啓動媒體播放器:開始叫狀態誤差(-38,0)
case position = 1 play audio1,
case position = 2 play audio2
但是,當我執行,播放一個錯誤並停止播放聲音。
start called in state error (-38, 0)
的活動:
public class HomeEnglishFoodsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_english_foods);
GridView gridView = (GridView) findViewById(R.id.gridviewHomeEnglishFoods);
gridView.setAdapter(new AdapterHomeEnglishFoodsActivity(this));
final MediaPlayer mpApple = MediaPlayer.create(this, R.raw.apple);
final MediaPlayer mpBeer = MediaPlayer.create(this, R.raw.beer);
final MediaPlayer mpCoffee = MediaPlayer.create(this, R.raw.coffee);
final MediaPlayer mpCheese = MediaPlayer.create(this, R.raw.cheese);
final MediaPlayer mpFrenchfries = MediaPlayer.create(this, R.raw.frenchfries);
final MediaPlayer mpIcecream = MediaPlayer.create(this, R.raw.icecream);
final MediaPlayer mpHotdog = MediaPlayer.create(this, R.raw.hotdog);
final MediaPlayer mpWine = MediaPlayer.create(this, R.raw.wine);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
switch (position) {
case 0:
mpApple.start();
break;
case 1:
mpBeer.start();
break;
case 2:
mpCoffee.start();
break;
case 3:
mpCheese.start();
break;
case 4:
mpFrenchfries.start();
break;
case 5:
mpIcecream.start();
break;
case 6:
mpHotdog.start();
break;
case 7:
mpWine.start();
break;
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_home_english_foods, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
錯誤:
06-04 00:46:21.334 17752-17752/br.gabrielrossetto.tap4learn E/MediaPlayer﹕ Error (-19,0)
06-04 00:46:29.612 17752-17752/br.gabrielrossetto.tap4learn E/MediaPlayer﹕ start called in state 0
06-04 00:46:29.612 17752-17752/br.gabrielrossetto.tap4learn E/MediaPlayer﹕ error (-38, 0)
06-04 00:46:29.652 17752-17752/br.gabrielrossetto.tap4learn E/MediaPlayer﹕ Error (-38,0)
你檢查這些http://stackoverflow.com/questions/9888510/mediaplayer-error-19-0-after-repeated-plays http://stackoverflow.com/questions/16172496/mediaplayer -error-19-0-doesnt-work-release- –
我使用版本,但不播放音頻。剛開始玩。 –