Android videoview tutorial in aide ide


Tutorial on how to implement videoview in aide ide, using videoview you can play video from your asset folder or from url, videoview support mp3 streaming.
The VideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting, for more info about videoview please visit this link: https://developer.android.com/reference/android/widget/VideoView

If you looking for advance videoplayer i recommend to use exoplayer by google.

In this tutorial im using video from url or video that upload on internet.

Now lets start coding, first goto your "AndroidManifest.xml" and add this two permission
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Next goto your java files e.g "MainActivity.java" and add this code below:
VideoView videoView = (VideoView) findViewById(R.id.view);
MediaController controller = new MediaController(this);
videoView.setVideoPath("https://archive.org/download/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4");
videoView.setMediaController(controller);
videoView.start();

And last the step, in your layout files:
<VideoView
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />


The result it look like this.
android videoview

Adding popup loading dialog, use this following code in your java files.
// Declare variables
ProgressDialog pDialog;
VideoView videoview;

videoview = (VideoView) findViewById(R.id.view);
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setTitle("Video Streaming");
pDialog.setMessage("Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();

try {
MediaController mediacontroller = new MediaController(
MainActivity.this);
mediacontroller.setAnchorView(videoview);
Uri video = Uri.parse("http://www.androidbegin.com/tutorial/AndroidCommercial.3gp");
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);

} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}

videoview.requestFocus();
videoview.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
videoview.start();
}
});

play videos from url in aide ide


End of tutorials.

Comments

Popular posts from this blog

Implement in-app purchase in aide ide

Implement google admob interstitial ads in aide ide

Implement a-ads on blogger or website

Android play .gif file on imageview in aide ide

Aide ide tutorial - Add line graph


Malitanyo Developer blog & tutorial 2020
Refund Policy    Facebook Page    Google Play

Blogger.com