I have watched many tutorials but somethings wrong. I have simple mainactivity and there is a VideoView on the it's layout. I downloaded a video from youtube as a .mp4 file size is about 10 mb. I found a great sample about videoview on youtube as the following link.
https://www.youtube.com/watch?v=tPeDn18FrGY&t=75s
ublic class MainActivity extends AppCompatActivity {
private VideoView bgVideo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bgVideo=(VideoView) findViewById(R.id.bg_videoview);
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.bgvideo);
bgVideo.setVideoURI(uri);
bgVideo.start();
bgVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
}
}
I use genymotion emulator. While i run the app i take "can't play this" error. And at the android monitor things like this.
06-07 03:16:28.675 2146-2146/com.sample E/MediaPlayer: Error (1,-2147483648)
06-07 03:16:28.675 2146-2146/com.sample D/VideoView: Error: 1,-2147483648
06-07 03:16:28.692 2146-2146/com.sample E/MediaPlayer: Error (1,-2147483648)
06-07 03:16:28.692 2146-2146/com.sample D/VideoView: Error: 1,-2147483648
06-07 03:16:28.709 2146-2146/com.sample E/MediaPlayer: Error (1,-2147483648)
06-07 03:16:28.709 2146-2146/com.sample D/VideoView: Error: 1,-2147483648
06-07 03:16:28.742 2146-2146/com.sample E/MediaPlayer: Error (1,-32)
06-07 03:16:28.742 2146-2146/com.sample D/VideoView: Error: 1,-32
06-07 03:16:28.758 2146-2146/com.sample E/MediaPlayer: Error (1,-38)
06-07 03:16:28.758 2146-2146/com.sample D/VideoView: Error: 1,-38
06-07 03:16:29.526 2146-2146/com.sample I/Choreographer: Skipped 44 frames! The application may be doing too much work on its main thread.
How can i fix it ?