MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.my_video); // Create a MediaPlayer instance int videoWidth = mediaPlayer.getVideoWidth(); // Get the width of the video
MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource("http://example.com/my_video.mp4"); // Set the data source to a video file on the internet mediaPlayer.prepare(); // Prepare the player asynchronously int videoWidth = mediaPlayer.getVideoWidth(); // Get the width of the videoIn this example, we create a MediaPlayer instance and set its data source to a video file streamed over the internet. We then call the prepare() method asynchronously to prepare the player for playback, and finally retrieve the width of the video using getVideoWidth(). Package library: android.media.