Widget - Video View

// add a Button button1 and a LinearLayout linear2.
// Create a String List list, and a String variable str.
// Add a FilePicker component fp with mime type video/
// Create a more block extra.
// In the more block extra.
}
VideoView vidview;
MediaController mediaControls;
{

// In onCreate event,

vidview = new VideoView(this);
vidview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
linear2.addView(vidview);

mediaControls = new MediaController(this); mediaControls.setAnchorView(vidview); vidview.setMediaController(mediaControls);
vidview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
}});

vidview.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
showMessage("Oops An Error Occured While Playing Video!!");
return false;
}});


// In button1 onClick event use the block FilePicker pick files.
// In the event FilePicker onFilesPicked.
// set String str to get at 0 of List String filePath
// and add
vidview.setVideoURI(Uri.parse(str));
vidview.start();



// or set OnPreparedListener event on VideoView, and play the video when it is ready to play.
vidview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
vidview.start();

}}); 

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation