我有一个Android活动,我将视频加载到视频中并进行播放。问题是,当我启动活动时,屏幕呈黑色约15秒,然后才会出现任何内容并播放视频。这是我的代码。
public class welcomevideo extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcomevideo);
VideoView vidView = (VideoView)findViewById(R.id.myVideo);
String vidadress = "**";
Uri vidUri = Uri.parse(vidadress);
vidView.setVideoURI(vidUri);
MediaController vidControl = new MediaController(this);
vidView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
Intent setIntent = new Intent(welcomevideo.this,AllGameslistActivity.class);
startActivity(setIntent);
finish();
}
});
vidControl.setAnchorView(vidView);
vidView.setMediaController(vidControl);
vidView.start();
}
@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_welcomevideo, menu);
return true;
}
public void yoe(View v) {
Intent e = new Intent(welcomevideo.this,AllGameslistActivity.class);
startActivity(e);
finish();
}
@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);
}
@Override
public void onBackPressed() {
Intent setIntent = new Intent(welcomevideo.this,AllGameslistActivity.class);
startActivity(setIntent);
finish();
}
@Override
protected void onPause()
{
super.onPause();
//closing transition animations
overridePendingTransition(R.anim.activity_open_scale, R.anim.ctivity_close_translate);
}
}