-1

I have uploaded a video in my recourses file in android studio and I want to play the video offline in my app my video is of 1 MB but when I run my app it throws an error

error (1, -2147483648)

and a pop up shows up that Video can not be played.

E/SurfaceSyncer: Failed to find sync for id=0 
E/MediaPlayerNative: error (1, -2147483648) 
W/Parcel: Expecting binder but got null! 
E/MediaPlayer: Error (1, -2147483648) 
D/VideoView: Error: 1,-2147483648

This is my Main class code

package com.example.igea;


import...

public class MathsChap1 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maths_chap1);
        Button bb = findViewById(R.id.ibk);
        bb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent( packageContext: MathsChap1.this, Maths.class); 
                startActivity(i);
            }
        });
        VideoView v1 = findViewById(R.id.vv1);
        v1.setVideoPath("android.resources://" + getPackageName() + "/" + R.raw.video1);
        MediaController mc = new MediaController( context: this);
        v1.setMediaController(mc);
        mc.setAnchorView(v1);
        v1.start();


    }
}

Can someone please help me with this error?

moken
  • 3,227
  • 8
  • 13
  • 23
  • You may check if any suggestion [here](https://stackoverflow.com/questions/11540076/android-mediaplayer-error-1-2147483648) can help. – Enowneb Jan 31 '23 at 08:37

1 Answers1

0

You can use MediaPlayer

MediaPlayer mediaPlayer;
mediaPlayer = MediaPlayer.create(this, R.raw.your_video_file);
mediaPlayer.start();
Sachin Solanki
  • 79
  • 2
  • 15