What is wrong in following create method of MediaPlayer
? I have passed the required parameters correctly.
import android.media.MediaPlayer;
public class Splash extends Activity {
MediaPlayer intro;
@Override
protected void onCreate(Bundle sScreen) {
super.onCreate(sScreen);
setContentView(R.layout.splash);
intro = new MediaPlayer.create(Splash.this, R.raw.tingting);
intro.start();
}
@Override
protected void onPause(){
super.onPause();
intro.release();
finish();
}
}
create()
is a Factory method .
[Creating the object] is done by by calling a factory method [...] rather than by calling a constructor.
You do not need to call new
, this is done automatically by MediaPlayer.create
:
intro = MediaPlayer.create(Splash.this, R.raw.tingting);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.