Tasker - Play video using MX Player while another is currently playing


Question

I have an Android mini-pc connected to a television through a HDMI cable. I use Tasker to automatically start playing an mp4 video using MX Player when the device boots. MX Player then continues to play all the videos from the same folder in a random order and on a loop.



(the task contains one action - Open File - under File I have the path to the mp4 file )



The problem is I then have Tasker set to play another mp4 video (from another directory) using MX Player one hour after the device has booted but MX Player ignores this and continues to play the current video.



(the second task is the same as the first- it contains one action - Open File - under File I have the path to the mp4 file )



The reason why I need to use MX Player (instead of BS Player, VLC etc.) is because it has more options than the other players like the option to play all the videos in the same folder in shuffle and on a loop, resize the video so it fills the screen, play each video from the beginning and hide the video controls from the screen.



I have also tried using the Tasker action Send Intent




  • Action: android.intent.action.VIEW

  • Data: path to mp4 file

  • Package: com.mxtech.videoplayer.ad

  • Target: Activity



But this produced the same results - As MX Player was playing a video this task would run telling it to play a video and MX Player would ignore it and continue to play its current video.



Is there any way of getting Tasker to play a video using MX Player while MX Player is currently playing another video?


Answer

I cannot give my assurance for the mini-PC you've got, but the following works well on my Nexus 6 running stock Android 6.0.1 with MX Player v1.8.3.



Alright, so discard whatever actions you've setup and follow this simple one:



Code → Run Shell →




  • Command:



    am start -n com.mxtech.videoplayer.ad/.ActivityScreen -d "file://FILE" --user ID --activity-clear-task


    where,




    • FILE refers to the location of your media file in Android. E.g. /sdcard/Movies/lolcat.mkv, /storage/emulated/0/Prime_time/after_dark.mkv and so on.

    • ID refers to the ID of the user account currently active. For primary user, it is always 0.

    • --activity-clear-task is a flag which makes sure no multiple instances of the same activity are spawned.




    Example command:



    am start -n com.mxtech.videoplayer.ad/.ActivityScreen -d "file:///sdcard/Movies/The egg of the King.mp4" --user 0 --activity-clear-task


    If MX Player is the default video player in your Android, for fun, you can replace -n com.mxtech.videoplayer.ad/.ActivityScreen with -a android.intent.action.VIEW in the said command.


  • tick Continue Task After Error




You can now setup a wait timer or anything that you intend to do after the execution of that action. In order to fire a new video, just copy everything from aforesaid action except of FILE which needs to be replaced with new file location.



In case Tasker doesn't work out, try with Automate. It has a neat block named App Start which is specifically meant to launch an activity of an app.



(Click image to enlarge it)



IMG:


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes