Posts

Showing posts with the label Play video url in VideoView

Play a video from its url

Image
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