tccoin / Jellyfin-Potplayer

Play with Potplayer
106 stars 26 forks source link

Potplayer just won't start #5

Open acwuxiao opened 3 years ago

acwuxiao commented 3 years ago

Can't open any file with Potplayer, until I realize it might be some problem with Powershell Execution Policy Run PowerShell as administrator get-ExecutionPolicy It's probably "Restricted" if you're having the same problem as mine, if so, just change it set-ExecutionPolicy RemoteSigned Voila, all set, enjoy

tccoin commented 1 year ago

Thank you for the advice! I will add it to the readme file.

AziRizvi commented 2 weeks ago

I modified this script to work with MPV Player but I just couldn't get it to work with the powershell script, I "unblocked" the file which was blocked because it came from "another computer" and I also tried setting up the execution policy via opening powershell and also by trying to set the execution policy via the group policy editor, it just wouldn't work.

So instead, I found a solution using AutoHotKey, install Autohotkey (V1) from here https://www.autohotkey.com after doing that, go to any folder, right click > new > AutoHotKey script and then just copy the code below (change all text that says mpv to potplayer) and paste the code that's below into that file and save it, after saving it, go where the file's located and right click on the file and you'll get a compile script option, click on that and it'll get compiled to a .exe file then in the registry entry, make sure you set the path to this file instead of the powershell script, the AutoHotKey script fulfills the same function as the powershell script which was to decode the path of the file and then run the video player with that path. (At the very end, I've also attached a short video showing it in action, I think with the original powershell script, it displayed the shell window for a second before launching the video player but with this, it's seamless, no popups or anything.)

This is what the registry entry would look like: (Make sure you modify it with the path to the .exe file you just compiled) J:\Portable-Softwares\Jellyfin-Scripts\Launcher.exe %1

The AutoHotKey Script: (This is set up to work with MPV player, just replace everywhere it says mpv with potplayer)

;; Get The Path From The Command Line Argument (the mpv:// path)
Path := A_Args[1]

;; Remove The mpv:// Prefix & Modify The Drive Path Correctly.

Path := StrReplace(Path, "mpv://A/", "A:/")
Path := StrReplace(Path, "mpv://B/", "B:/")
Path := StrReplace(Path, "mpv://C/", "C:/")
Path := StrReplace(Path, "mpv://D/", "D:/")
Path := StrReplace(Path, "mpv://E/", "E:/")
Path := StrReplace(Path, "mpv://F/", "F:/")
Path := StrReplace(Path, "mpv://G/", "G:/")
Path := StrReplace(Path, "mpv://H/", "H:/")
Path := StrReplace(Path, "mpv://I/", "I:/")
Path := StrReplace(Path, "mpv://J/", "J:/")
Path := StrReplace(Path, "mpv://K/", "K:/")
Path := StrReplace(Path, "mpv://L/", "L:/")
Path := StrReplace(Path, "mpv://M/", "M:/")
Path := StrReplace(Path, "mpv://N/", "N:/")
Path := StrReplace(Path, "mpv://O/", "O:/")
Path := StrReplace(Path, "mpv://P/", "P:/")
Path := StrReplace(Path, "mpv://Q/", "Q:/")
Path := StrReplace(Path, "mpv://R/", "R:/")
Path := StrReplace(Path, "mpv://S/", "S:/")
Path := StrReplace(Path, "mpv://T/", "T:/")
Path := StrReplace(Path, "mpv://U/", "U:/")
Path := StrReplace(Path, "mpv://V/", "V:/")
Path := StrReplace(Path, "mpv://W/", "W:/")
Path := StrReplace(Path, "mpv://X/", "X:/")
Path := StrReplace(Path, "mpv://Y/", "Y:/")
Path := StrReplace(Path, "mpv://Z/", "Z:/")

;; Replace %20 With A WhiteSpace Character.
Path := StrReplace(Path, "%20", " ")

;; Decode The Path URL.
DecodedPath := Decoder(Path)

;; Function To Decode The Path Url.
Decoder(url) 

    {
        VarSetCapacity(Out, StrPut(url, "UTF-8") + 1, 0)
        StrPut(url, &Out, "UTF-8")
        return StrGet(&Out, "UTF-8")
    }

;; Launch MPV With The Decoded Path.
Run, "J:\\Portable-Softwares\\MPV\\mpv.exe" "%DecodedPath%"

Return
ExitApp

https://github.com/user-attachments/assets/9942eca2-5593-47ae-bfba-4d7d4d4f7b5d

AziRizvi commented 2 weeks ago

I was finally able to get the powershell script working today by editing it to this, I hope this helps someone who was facing the same issue of the window flashing for a second but the video player not launching.

Add-Type -Assembly System.Web
$path=$args[0]
$path=$path -replace "potplayer://A/" , "A:/"
$path=$path -replace "potplayer://B/" , "B:/"
$path=$path -replace "potplayer://C/" , "C:/"
$path=$path -replace "potplayer://D/" , "D:/"
$path=$path -replace "potplayer://E/" , "E:/"
$path=$path -replace "potplayer://F/" , "F:/"
$path=$path -replace "potplayer://G/" , "G:/"
$path=$path -replace "potplayer://H/" , "H:/"
$path=$path -replace "potplayer://I/" , "I:/"
$path=$path -replace "potplayer://J/" , "J:/"
$path=$path -replace "potplayer://K/" , "K:/"
$path=$path -replace "potplayer://L/" , "L:/"
$path=$path -replace "potplayer://M/" , "M:/"
$path=$path -replace "potplayer://N/" , "N:/"
$path=$path -replace "potplayer://O/" , "O:/"
$path=$path -replace "potplayer://P/" , "P:/"
$path=$path -replace "potplayer://Q/" , "Q:/"
$path=$path -replace "potplayer://R/" , "R:/"
$path=$path -replace "potplayer://S/" , "S:/"
$path=$path -replace "potplayer://T/" , "T:/"
$path=$path -replace "potplayer://U/" , "U:/"
$path=$path -replace "potplayer://V/" , "V:/"
$path=$path -replace "potplayer://W/" , "W:/"
$path=$path -replace "potplayer://X/" , "X:/"
$path=$path -replace "potplayer://Y/" , "Y:/"
$path=$path -replace "potplayer://Z/" , "Z:/"

$path= [System.Web.HttpUtility]::UrlDecode($path)
echo $path
& "J:\\Portable-Softwares\\potplayer\\potplayer.exe" $path