Sunday, October 13, 2019

#1 2018-11-20 08:56:19 am

derekp13
Member
Registered: 2018-11-19
Posts: 1

Automator + Portable VLC?

I have a video file on a USB flash drive, I want to set it up so that you can click the Automator Application and have it open immediately in the Portable VLC also on the flash drive. So the viewer doesn't need to install VLC or do any other messing around.
I've tried several recipes in various orders; VLC opens but the video will not auto play or show up in VLC.

The video will play in the Portable VLC by more standard methods.

Suggestions? Thank you!

Offline

 

#2 2019-03-16 12:05:43 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 614

Re: Automator + Portable VLC?

No needed Automator. Use script and save as application:

set my_Movie to alias "Untitled:Русские фильмы:1990:Заложница  (1990.DVDRip-AVC).mkv"
set my_Application to alias "Untitled:VLC.app:"


tell application "Finder"
    activate
    open my_Movie using my_Application
end tell


NOTE 1: Here Заложница  (1990.DVDRip-AVC).mkv is my movie name. Is stored in subfolder 1990 of subfolder Русские фильмы of USB disk Untitled.  Put your paths in lines of code 1 and 2, and you can use this script.

NOTE 2: You can play VLC of startup disk and VLC of USB disk at the same time!!!

NOTE 3: Code line 1 is better to replace with set my_Movie to choose file. Then you can choose other movies from USB and from startup disks.

----------------------------------------------------------------------------------------------------------------------------

More professional script will be that:

set timeoutSeconds to 2.0

set uiScript to "set my_Movie to choose file
set my_Application to alias \"Untitled:VLC.app:\"
open my_Movie using my_Application"


my doWithTimeout(uiScript, timeoutSeconds)

on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"Finder\"
            activate
" & uiScript & "
end tell"
            exit repeat
        on error errorMessage
            if ((current date) > endDate) then
                error "Can not " & uiScript
            end if
        end try
    end repeat
end doWithTimeout


----------------------------------------------------------------------------------------------------------------------------

You can make this script your own (custom) Automator service too. All custom services autosaved by Automator in ~/Library/Services. As this is now real service, you can find it in Services menu with right clicking movies too. Here is steps for creating similar service:

----------------------------------------------------------------------------------------------------------------------------
1) Open Automator
2) In the window that pops up, highlight Service and then hit Choose.
3) Now in the Library section on the left, click on Utilities and then find Set Value of Variable. Drag it to the main window on the right.
4) In the Variable dropdown, choose New variable… and call it original_Movies
5) In the Service receives selected choose Movie files
6) Set the in dropdown to Finder.app
7) Still in the Utilities section of the Library on the left, find Run AppleScript. Drag it to the main window under our last step.

Opens shell-script:

on run {input, parameters}
   
    (* Your script goes here *)
   
    return input
end run


8) Replace (* Your script goes here *) with our script lines:

set timeoutSeconds to 2.0

set uiScript to "set my_Movie to choose file
set my_Application to alias \"Untitled:VLC.app:\"
open my_Movie using my_Application"


my doWithTimeout(uiScript, timeoutSeconds)

9) After the sentence end run leave blank line and add our entire handler doWithTimeout:

on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"Finder\"
            activate
" & uiScript & "
end tell"
            exit repeat
        on error errorMessage
            if ((current date) > endDate) then
                error "Can not " & uiScript
            end if
        end try
    end repeat
end doWithTimeout


10}: Go to File > Save and give your new service a name. I’ll call mine USB_VLC_Player.

You have just created a Service. This means that if you right-click anybody movie, you can see service USB_VLC_Player, choose it and choose anybody other movie for playing with VLC on USB .
----------------------------------------------------------------------------------------------------------------------------

Of course, whenever the USB currently isn't mounted, subroutine doWithTimeout will throw error with message and stop execution.

I prepared ready workflow. You can download it from Here  (clickable reference from DropBox)

Open workflow and edit only рath to your own USB device VLC player (replace only Untitled:VLC.app: with your own path). Then move workflow to folder ~Library/Services.

You can define exactly path to your own USB device VLC player by running in Script Editor this simple code:

set myVLC_Path to choose file

Connect USB, run code, click USB icon, find VLC, choose it and copy from Results window the path {you need here only the  piece between quotes)

For example, my result was that:

alias "Untitled:VLC.app:"

As you can see, I had copy only bold here text. This is so as not to confuse you with escaping quotes nested in other quotes. That's all.

Last edited by KniazidisR (2019-03-16 04:22:41 am)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)