无法从原始文件夹播放mp3文件

时间:2011-11-29 02:16:35

标签: android

我编写的代码编译干净而且很好,并且没有错误。我在市场上发布的其他应用程序中使用了相同的代码。当我更新ADT时出现了问题。我逐步阅读了关于清理它的帖子,在获得最新更新时,我的应用程序没有任何效果。它不播放原始文件中的声音。它就像是没有Raw文件夹。它编译没有问题,但不播放MP3。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

公共类UpdatecodeActivity扩展了Activity {

MediaPlayer mp1, mp2;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mp1 = MediaPlayer.create(this, R.raw.wait);
    mp2 = MediaPlayer.create(this, R.raw.primates);

    //Button coding for menu and items 
    Button btn1 = (Button) findViewById(R.id.btn1);
    registerForContextMenu(btn1);
    btn1.setOnClickListener(this);
    Button btn2 = (Button) findViewById(R.id.btn2);
    registerForContextMenu(btn2);
    btn2.setOnClickListener(this);
}//Closing tag for OnCreate

//OnClick handler for multiple buttons
public void onClick(View v){
    if (v.getId() == R.id.btn1) {
        // action to perform on button 1

         mp1.start();

    } else if (v.getId() == R.id.btn2) {
        // action to perform on button 1

        mp2.start(); 


    }//Closes Onclick Switches
}//Closes onclick
相关问题