Showing posts from May, 2020

Display video thumbnails in firebase chat

To upload and display video thumbnail in a firebase based chat in Sketchware, follow the steps given below. 1. On the chat page add a file picker to pick files (mime type */*). 2. Add an ImageView imageview1 for picking files. 3. In imageview1 onClick event use file picker to pick files. 4. Create a String variable path . 5. In file picker onFilesPicked event, set String path to the path of the file selected. 6. In the event of button1 onClick (send button), if String path is not empty, upload the file to Firebase storage. 7. Add a String variable thumb_String . 8. In the event Firebase storage onUpload success , if the file selected is a video, create thumbnail from the path , convert it to base64 String, and send the url of the video (using key "attachment") and the thumbnail in String form (using key "thumbnail")  to firebaseDb. The code used here is: Bitmap bitmap =ThumbnailUtils.createVideoThumbnail(path, android.provider.MediaS

Play a video from its url

If you have a video in firebase database and you want to play it in a VideoView in Sketchware, follow the steps given below. 1. Create a new Activity PlayVideoActivity . 2. In View settings remove status bar and toolbar, and set screen orientation to both portrait and landscape. 3. Create a String variable url . 4. In onCreate , set url to the video url. 5. In onCreate event: // Define a FrameLayout. FrameLayout layout = new FrameLayout(this); FrameLayout.LayoutParams layoutparams=new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); layout.setLayoutParams(layoutparams); // Define VideoView and MediaController. final VideoView vidview = new VideoView(this); FrameLayout.LayoutParams vvlp =  new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); vidview.setLayoutParams(vvlp); final MediaController mediaContr

BarChartView in Sketchware

In Sketchware project, if you have a List Map containing a key with numerical values, it can be displayed in a graph form using the BarChartView code created by me. Follow the steps given below to understand how to use it. 1. Create a new page graph.xml to display the bar chart. 2. On the page containing the List Map, add a button to move to . In the event of Button onClick , save List Map in Intent put Extra key "list" by converting it to Json String and then move to . 3. In  graph.xml  add a LinearV  linear1 . 4. In  add a ListMap  listmap . 5. In  onCreate  event use blocks to get json string in Intent extra key "list", and convert it to listmap . Then use codes to display this ListMap in BarChartView. The code used in add source directly block is BarChartView chart = new BarChartView(this, listmap, "totalConfirmed", "loc"); linear1.addView(chart); Here 'l