I know this has been asked many times. I've tried out many of the solutions mentioned previously like increasing API level, changing android device, changing video, changing vide format. The same error each time. I am using Nexus 6p, running Oreo 8.1 and the minimum API is like from Marshmellow. xml code:
<VideoView
android:background="@color/colorPrimaryDark"
android:layout_height="600dp"
android:layout_width="fill_parent"
android:id="@+id/VideoView" />
<Button
android:text="@string/play"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onButtonClick"
android:background="@color/colorPrimary"
android:id="@+id/button"/>
java code:
public class IntroVideoActivity extends AppCompatActivity {
VideoView VideoView;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intro_video);
VideoView = (VideoView) findViewById(R.id.VideoView);
button = (Button) findViewById(R.id.button);
}
public void onButtonClick (View v) {
String videopath = "android.resource://com.example.nisat.favor"+R.raw.anime;
Uri uri = Uri.parse(videopath);
VideoView.setVideoURI(uri);
VideoView.start();
}
}
I've tried this code aswell:
VideoView videoView = (VideoView)findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoPath("vectorvideo");
videoView.start();