hwoarang69 11 Newbie Poster

i am trying to play music when my app start but
this line is giving me a error. on 'res'. so i have a project called ANDROID_01
ANDROID_01 > res > sound

 ourSong = MediaPlayer.create(Splash.this, R.res.sound.intro);





 my folder tree
 ANDROID_01
     assets
     bin
     gen
     libs
     res
         drawable
         layout
         menu
         sound
             intro.mp3
     values
     src
     ...

full code

package com.example.android_01;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.*;

public class Splash extends Activity
{
    MediaPlayer ourSong;

     @Override
      protected void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash);

           /*** play song ***/
            ourSong = MediaPlayer.create(Splash.this, R.res.sound.intro);
            ourSong.start();


            /*** wait for 5 sec than run different screen ***/
            Thread timer = new Thread()
            {
                public void run()
                {
                    try
                    {
                        sleep(5000); //wait 5 second
                    }
                    catch(InterruptedException e)
                    {
                        e.printStackTrace();  //catch errors
                    }
                    finally
                    {
                        // after 5 second start StartingPoint file
                        Intent openStartingPoint = new Intent("com.example.android_01.STARTINGPOINT");
                        startActivity(openStartingPoint);
                    }
                }
            }; 
            timer.start();
        }/***end of onCreate ***/




     /*** kill splash page when 5 sec are over ***/
     @Override
     protected void onPause()
     {
         //TODO Auto-generated metod stub
         super.onPause();
         ourSong.release(); //stop music
         finish();          //kill splash file
     }/*** end of onPause ***/ 
}/*** end of class ***/
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.