Starting a video playing automatically

Hi,

While developping an app

  • with a button (and a counter of the clicks)
  • and displaying text (connected to the click number)
  • should also display a short video (connected to the click number)

This video should start playing automatically and stop/disappear at the end.

From PuraVida I found 2 blocks to solve the start playing automatically, but I don’t understand the used clock feature. Before I used them, I produced a result with manually start. Now nothing starts….

I attach my blocks, a screenshot and hope to get a hint


which timer interval did you use for the clock?
why a clock component is required was explained here Redirecting to Google Groups

yes, you re correct, it seems to not work directly in the Screen.Initialize event
as workaround just use a clock component (timer interval = 100ms) to start the video a little bit later... see screenshot and example project

Taifun


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

2 Likes

[quote=“Taifun, post:2, topic:5215”]
which timer interval did you use for the clock?
[/quote] thank you for the reply…

I did not use any timer interval. The documentation on the component “Clock” is all Greek to me. I find no reference to the special clock blocks (there is nothing explained, blocks are only explained for built-in blocks) Can you show me the use of a timer interval in the blocks and where I should put it in?
Thank you

Meanwhile I found the clock-timer-intervall block and put it together like the following:

well, everything is explained in the documentation for each property and method... and some properties you also can set in the designer...
you can find the documentation of the Clock component here https://i.stack.imgur.com/4mmH1.jpg

TimerEnabled

Specifies whether the Timer event should run.

TimerInterval

Specifies the interval between subsequent Timer events.

to set the timer interval inside the Clock.Timer event does ot make much sense...
why don't you follow my example?
set it in the designer or during Screen.Initialize and start the clock there
it does not make much sense to repeat everything again, does it?
what about downloading the example app from here Redirecting to Google Groups to test it on your device? does it work?

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials Our Tutorials! to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


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

1 Like

How do I start the clock?

Meanwhile I checked in the Designer the Clock:

  • Timer intervall = 100

  • TimerEnabled = false

  • TimerAlwaysFires = false

In the Blocks I cancelled all blocks with a "timerEnabled"

Meanwhile I get the video open/displayed, but only for manual start and without manual or automatic stop/disappearence

I attach the updated list of blocks

Meanwhile I managed the automatic start and stop/disappearence of the video.

So the main problem seems to be solved. I thank you Taifun for all your hints. There is plenty to study and trying…of course

regards/opowoj

Sorry, but I have to come back:
My app is working with the videoplayer correct with the MIT AI2 Companion, but does not work at all on my real Smartphone offline. I have no idea, what could be done …

Here you go with the latest version of the blocks

and I attach the aia-file

CameraObscura.aia (1.3 MB)

as already said earlier

Taifun

Hello Taifun,
thank you for your reply.

  • I installed your aia file on my smartphone (Galaxy S5 neo) and it works

  • I checked the timer intervall with 100 in the clock component area, as you did
    (no other checks there)

  • I prepared the blocks as you did (see below)

  • I have an additional block “When VideoPlayer” completed, do “call VideoPlayer stop” and “set VideoPlayer visible false”

  • Still irritating is, that the app functions properly with the Companion, but not installed on my Smartphone

  • I have the same situation, when I augment the intervall from 100 to 200

Meanwhile I tried the timer intervall with 50 and with 400, but same situation…

For me it’s working.

Remove the VideoPlayer.Source to cameraflashes0202.mp4 block from Screen1.Initialize (since there is no such file in the assets):

1 Like

I love you Anke,

now it works!!!

(I uploaded the “cameraflashes0202.mp4” into the Source storage)

Best regards and compliment for your eagle eyes…
opowoj

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.