Select videos on the device and return the path

98 views
Skip to first unread message

Antonio Vitolo

unread,
Nov 15, 2018, 2:53:05 AM11/15/18
to MIT App Inventor Forum
Hi,

is there a component or extension such as imagepicker to select videos on the device and return the path?

Thanks.

SteveJG

unread,
Nov 15, 2018, 9:04:40 AM11/15/18
to MIT App Inventor Forum
You might be able to use Taifun's File extension.  There is no specific tool in the basic App Inventor 2 components.

File Extension  can be used to provide a list of videos by checking for their  file extension  *.mp4.  



Did this help Antonio?

Regards,
Steve


Antonio Vitolo

unread,
Nov 16, 2018, 3:04:05 AM11/16/18
to MIT App Inventor Forum

well it works, thank you !!


but how can I avoid that the user pauses the video?


I can hide the commands:


Screenshot_2018-11-16-08-59-28.png


Chris Ward

unread,
Nov 16, 2018, 8:33:32 AM11/16/18
to MIT App Inventor Forum
Hi Antonio

What exactly is that video player? If it is the App Inventor Player, you can simply ignore the pause button (do not include an event for it in your code Blocks).

Antonio Vitolo

unread,
Nov 16, 2018, 9:48:21 AM11/16/18
to MIT App Inventor Forum
VIDEOPLAYER is a component of appinventor 2, I can not ignore the pause or play button because it does not include events! it would have been too easy ...

how to do?

Chris Ward

unread,
Nov 16, 2018, 11:03:28 AM11/16/18
to MIT App Inventor Forum
Hi Antonio

You are right, that is a huge oversight in App Inventor - If you create your own controls for the Video Player Events provided, they will simply be ignored if the User taps the Player to reveal it's built-in controls bar.

I trying to find a work-around.

Chris Ward

unread,
Nov 16, 2018, 11:31:02 AM11/16/18
to MIT App Inventor Forum
Hi again Antonio

OK. Workaround:
  • Define an HTML file using CSS to define the Video Player without User Controls
  • This file is displayed in App Inventor's WebViewer component
  • App Inventor has a small javascript function that allows it to communicate with the HTML file:

You can use the WebViewer.WebViewString property to communicate between your app and Javascript code running in the Webviewer page. In the app, you get and set WebViewString. In the WebViewer, you include Javascript that references the window.AppInventor object, using the methods and setWebViewString(text).

For example, if the WebViewer opens to a page that contains the Javascript command
document.write("The answer is" + window.AppInventor.getWebViewString());
and if you set WebView.WebVewString to "hello", then the web page will show
The answer is hello.
And if the Web page contains Javascript that executes the command
window.AppInventor.setWebViewString("hello from Javascript"),
then the value of the WebViewString property will be
hello from Javascript. 



Chris Ward

unread,
Nov 16, 2018, 3:10:44 PM11/16/18
to MIT App Inventor Forum
Hi again Antonio

Well, really up against because, since April 2018, some committee or other decided that auto-play videos on websites must be muted (no sound). To play the sound, the User must be presented with controls so they are in charge of the play-back.

I also cannot get the WebViewer to play a video, which could just be me but the same html file does play in the main browser.

Antonio Vitolo

unread,
Nov 16, 2018, 3:59:41 PM11/16/18
to MIT App Inventor Forum
so a solution does not exist ... ???

Chris Ward

unread,
Nov 16, 2018, 5:11:06 PM11/16/18
to MIT App Inventor Forum
Hi Antonio

It would seem not, but maybe someone knows better than me and has another idea. There is a Video Player extension called Stream Player:


...it does not suppress the controls, but you could ask the developer if he can make that an option.

Taifun

unread,
Nov 17, 2018, 8:54:30 PM11/17/18
to MIT App Inventor Forum
I also cannot get the WebViewer to play a video, which could just be me but the same html file does play in the main browser.


To be able to play Youtube videos in the webviewer, you have to edit the manifest and add android:targetSdkVersion="14" or higher. See this thread how to do it. Thank you Boban! See also this tutorial by Juan Antonio.
and if you build the app using the "build app for Google Play" option, it should work in the apk file without modification of the manifest...

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.        

Chris Ward

unread,
Nov 18, 2018, 7:09:56 AM11/18/18
to mitappinv...@googlegroups.com
Hi Antonio

I think the next release of App Inventor, whose target is beyond v14 as per Juan's notes about modifying the manifest, should deliver a version of the WebViewer that will work. Not every Android device will support it.

Here is example code for the html file:

<!DOCTYPE html>
<html>
<body>
               <video width="560" height="320" autoplay loop muted>
                          <source src="MyVideo.mp4" type="video/mp4" />
               </video>
</body>
</html>

The code above runs the video without offering the User any controls. It also allows the video to be stored on the device, no internet connection required.

We don't know if, on Android, it is necessary to start in mute mode. If it is necessary, a work-around would be needed. Probably using Javascript to control the playback could allow the suppression of the controls, without muting.

Tnn

unread,
Nov 19, 2018, 4:39:07 AM11/19/18
to MIT App Inventor Forum
since I have to add this function urgently, could someone create a VIDEOPLAYER extension with the option to disable the controls?
also paying ...

Chris Ward

unread,
Nov 19, 2018, 5:16:50 PM11/19/18
to MIT App Inventor Forum
Tnn,

Contact the developers of the existing Video Player extensions.

See extensions library on Taifun's Website: https://puravidaapps.com/extensions.php

Reply all
Reply to author
Forward
0 new messages