Periodically play a video and switch apps

Post your questions and help other users.

Moderator: Martin

Post Reply
foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Periodically play a video and switch apps

Post by foxcorner » 01 Apr 2016 20:03

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

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Periodically play a video and switch apps

Post by Martin » 03 Apr 2016 19:06

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

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 17:19

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...

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 17:49

Making progress... It now plays the video. :) Thanks!

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 19:03

Is there an action to make a currently-running app the active one?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Periodically play a video and switch apps

Post by Martin » 05 Apr 2016 19:17

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.

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 19:21

Thanks, yes, I meant bringing it to the front. I'll try that action.

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 19:34

It works! Thanks for your help!

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 20:35

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. :)

foxcorner
Posts: 8
Joined: 01 Apr 2016 16:54
Location: Northern Colorado, USA
Contact:

Re: Periodically play a video and switch apps

Post by foxcorner » 05 Apr 2016 21:44

Figured it out. I've used an Expression, editing from 1==0 to 1==1.

Works well. :)

Post Reply