VideoView in Sketchware
To add a VideoView to play videos picked from Sdcard follow following steps in Sketchware.
1. Create a new project in Sketchware.
2. In VIEW area add a Button button1 and a LinearLayout linear2.
3. Create a String List list, and a String variable str.
4. Add a FilePicker component fp with mime type video/*.
5. Create a more block extra.
6. In the more block extra, use an add source directly block and put codes to declare a VideoView vidview and an MediaController mediaControls.
}
VideoView vidview;
MediaController mediaControls;
{
7. In onCreate event, use add source directly blocks and put following codes:
i. Define the VideoView vidview, set it's LayoutParams, and add it to the linear 2.
vidview = new VideoView(this);
vidview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
linear2.addView(vidview);
ii. Define the MediaController, anchor it to the VideoView, and set it as the MediaController of the VideoView.
mediaControls = new MediaController(this); mediaControls.setAnchorView(vidview); vidview.setMediaController(mediaControls);
iii. Set OnCompletionListener and OnErrorListener for the VideoView.
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; } });
8. In button1 onClick event use the block FilePicker pick files.
9. In the event FilePicker onFilesPicked, get file path of video picked to String str and set it as the Uri of the vidview.
Following code is used in the add source directly block.
vidview.setVideoURI(Uri.parse(str));
vidview.start();
10. Save and run the project. You can click the Button to pick any video. The picked video plays in VideoView.
* We can also 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();
} });
In this case we need not use vidview.start(); in FilePicker onFilesPicked event.
1. Create a new project in Sketchware.
2. In VIEW area add a Button button1 and a LinearLayout linear2.
3. Create a String List list, and a String variable str.
4. Add a FilePicker component fp with mime type video/*.
5. Create a more block extra.
6. In the more block extra, use an add source directly block and put codes to declare a VideoView vidview and an MediaController mediaControls.
}
VideoView vidview;
MediaController mediaControls;
{
7. In onCreate event, use add source directly blocks and put following codes:
i. Define the VideoView vidview, set it's LayoutParams, and add it to the linear 2.
vidview = new VideoView(this);
vidview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
linear2.addView(vidview);
ii. Define the MediaController, anchor it to the VideoView, and set it as the MediaController of the VideoView.
mediaControls = new MediaController(this); mediaControls.setAnchorView(vidview); vidview.setMediaController(mediaControls);
iii. Set OnCompletionListener and OnErrorListener for the VideoView.
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; } });
8. In button1 onClick event use the block FilePicker pick files.
9. In the event FilePicker onFilesPicked, get file path of video picked to String str and set it as the Uri of the vidview.
Following code is used in the add source directly block.
vidview.setVideoURI(Uri.parse(str));
vidview.start();
10. Save and run the project. You can click the Button to pick any video. The picked video plays in VideoView.
* We can also 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();
} });
In this case we need not use vidview.start(); in FilePicker onFilesPicked event.
can i pdf book View in Sketchware >> pdf to apk with sketchware ??
ReplyDeleteconvert the PDF to E PUB or to HTML, if you want to do it in sketchware, but you can design a PDF reader. if you want to create a PDF book, go to App maker App, you cam make the PDF APK and publish to google play.
Deletehere the link for App Maker App:
https://play.google.com/store/apps/details?id=com.appmaker.appmaker
device = android.os.Build.DEVICE;
ReplyDeletemodel = android.os.Build.MODEL;
product = android.os.Build.PRODUCT;
manufacturer = android.os.Build.MANUFACTURER;
brand = android.os.Build.BRAND;
api_level = android.os.Build.VERSION.SDK;
board = android.os.Build.BOARD;
boot = android.os.Build.BOOTLOADER;
display = android.os.Build.DISPLAY;
fingerprint = android.os.Build.FINGERPRINT;
hardware = android.os.Build.HARDWARE;
host = android.os.Build.HOST;
id = android.os.Build.ID;
Thanks dude !
ReplyDeleteI not have any developer account please help me to publish my first app in play store.
ReplyDeleteShall we pay 50% each
DeleteYou can upload them in aptoide
DeletePls tell me Loop options adding!
ReplyDeleteThis comment has been removed by the author.
ReplyDeletenima uchun shu kodlarni kucirip add dirctlyga tashlasam javaga xato chiqaradi javobini @First_blogger ga yozing
ReplyDeleteCan we load video from url
ReplyDeletePERFECT👌
ReplyDeleteCan we use vidview in listview
ReplyDeleteI personally tried this....
DeleteBut no
Kenapa finish activity tdk berfungsi,selalu kembali ke halaman sebelumnya??
ReplyDeleteThis comment has been removed by the author.
Deletehow can I fitch video from firebase storage in sketchware ?
ReplyDeleteJust you create a variable.... say like he had done it as file...
DeleteThe file must contain firebase video URL....
Just set up that and you will be done....
Just leave a thanks message if it does help you
Can i set my intro video in app
ReplyDeletePlease, can you write on how to save a video in app without going to the sdcard to pick a video
ReplyDeleteHow about customizing the media controller to my own custom view?
ReplyDeleteWhat about LOOP, REPEAT, it's possible to add to the code?
ReplyDeletevidview.setVideoURI(Uri.parse(str));
ReplyDeletevidview.start();
Can we open Camera on linear1 with our options like record button speed setting icon to add filter
ReplyDeletePlease How Can I implement Subtitles in video view in sketchware?
ReplyDeleteСкиньте мне готовый ваш пример (формат spk ) фоновое видео в приложении на почту мне, а я в долгу не останусь, моя почта:
ReplyDeletewmclicx@gmail.com
Please do you know how to implement subtitles in video player using Sketchware?
ReplyDelete