Page 1 of 1

Periodically play a video and switch apps

Posted: 01 Apr 2016 20:03
by foxcorner
Hi all,
I'm trying to achieve the following task:

* Launch a particular app (which shows status of something, not important what it is for this discussion)
(This action is already working under Automagic.)

* Loop start....

* Periodically launch a video player to play an 80-second video

* When the video's done, bring the status app to the front for, say, 80 seconds

* End loop


I can probably do this with a time delay loop in Automagic; but I'm not familiar with scripting
in android, so I don't know how to launch a video player to play a specific local video file.

Does anyone have any recommendations of which video player app has a command line
interface that would let me do this?

If so, how would I compose the Exexcute Command action? Or is there a different action
that would work better?

And how would I ensure that I don't get multiple instances of the video player? Does that
depend on the app's architecture? Or on how it's invoked from Automagic?

And is there an action which brings a running app to the front?

Android version is 4.1.2.

Thanks for any pointers!

Dan

Re: Periodically play a video and switch apps

Posted: 03 Apr 2016 19:06
by Martin
Hi,

You could try to play the video with action Start Activity. Following configuration might work, but this depends on video player:
Action: android.intent.action.VIEW
Data URI: file:///storage/emulated/0/video.mp4
Data MIME Type: video/*

It depends on video player if playback is started automatically or not.

You could use an action Sleep: 80s to wait in the loop.

Regards,
Martin

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 17:19
by foxcorner
Thanks, Martin, this is a great pointer. However, although it launches the video player, the path to the video's not right, so I need to download a file manager to get the "emulated" and "0" and so on right. However, for some reason Play Store can't connect to the internet (though Chrome can...). Working on this problem...

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 17:49
by foxcorner
Making progress... It now plays the video. :) Thanks!

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 19:03
by foxcorner
Is there an action to make a currently-running app the active one?

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 19:17
by Martin
Not sure what you mean. Is the app running in background and you want to bring it to the front or what do you mean by 'active'?

Often just starting the activity again works but this depends on app. You can also use action Start Activity with android.intent.action.MAIN and category android.intent.category.LAUNCHER and set explicit component to the app you'd like. This action simulates starting the app by the launcher/home screen. This procedure does not work with every app.

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 19:21
by foxcorner
Thanks, yes, I meant bringing it to the front. I'll try that action.

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 19:34
by foxcorner
It works! Thanks for your help!

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 20:35
by foxcorner
One final question...

Sometimes I'll want the flow to execute the first four nodes then stop.

At other times, I'll want it to execute the entire flow, where it enters a loop that plays the video in alternation with showing a realtime status app.

Is there an easy way to control whether it stops or runs on into the loop? I know I could add a condition that waits for something impossible to happen, and edit it when I want it to run on; but I'd like something a little more self-documenting than that. :)

Re: Periodically play a video and switch apps

Posted: 05 Apr 2016 21:44
by foxcorner
Figured it out. I've used an Expression, editing from 1==0 to 1==1.

Works well. :)