xfangfang / Macast

Macast is a cross-platform application which using mpv as DLNA Media Renderer.
https://xfangfang.github.io/Macast/
GNU General Public License v3.0
5.91k stars 373 forks source link

[Tutorial] Macast as headless DLNA renderer #155

Open bogie opened 1 year ago

bogie commented 1 year ago

Preface:

I was looking for a project like macast for quite some time, my priorities were not having to run a window manager on my headless living room server and being able to remotely cast video files on my TV.

My setup is a arch-linux server with a TV via HDMI and 5.1 analog sound system via pulseaudio, I use Jellyfin to cast my videos.

Prerequisites:

Configuration:

We will need to create and edit a few files by hand(I might create a AUR repository later):

/etc/systemd/system/macast.service

[Unit]
Description=Macast-gui (X11)
After=remote-fs.target systemd-user-sessions.service network-online.target nss-lookup.target sound.target bluetooth.target polkit.service upower.service mysqld.service lircd.service
Wants=network-online.target polkit.service upower.service
Conflicts=getty@tty1.service

[Service]
User=macast
Group=macast
PAMName=login
TTYPath=/dev/tty1
ExecStart=/usr/bin/xinit /usr/bin/macast-gui
ExecStop=/usr/bin/killall --user macast --exact --wait macast-gui.bin
Restart=on-abort
StandardInput=tty
StandardOutput=journal

[Install]
Alias=display-manager.service

Note the User=macast and Group=macast as well as the ExecStop --user macast switch, if you want to use a different user, make your changes here

run systemctl daemon-reload && systemctl start macast && systemctl stop macast

This will create the macast_setting.json in /home/macast/.config/Macast/

Next edit that file and make sure the following settings are set as follows: /home/macast/.config/Macast/macast_setting.json

"PlayerPosition": 4,
"PlayerSize":4,

This will run mpv/macast in the center as fullscreen, you can find compatible settings here: https://github.com/xfangfang/Macast/blob/937891b99f25f12ed788c98f988b1ce530c77e4e/macast_renderer/mpv.py#L482-L506

Usage:

Now run macast: systemctl start macast and optionally run macast on boot: systemctl enable macast

bogie commented 1 year ago

I did not find out what the difference between macast-cli and macast-gui is, also as a caveat you will not be able to access the context menu of the macast tray icon and as such edit settings on the tv itself.

Maybe we can get a way to access the settings via a browser, as the underlying code is already using web pages for configuration. However when trying to access the settings via the browser(http://ip:49571/dlna/setting.html) I got some vue errors.

Uncaught ReferenceError: VueI18n is not defined at setting.html:380:18

xfangfang commented 1 year ago

Thank you very much for writing such a detailed tutorial for Macast.

macast-gui will try to display an icon in the status bar. It works well on macOS and Windows, but cannot be displayed or clicked on some Linux. (https://github.com/xfangfang/Macast/wiki/Installation#linux)


Uncaught ReferenceError: VueI18n is not defined at setting.html:380:18

I don't know why this problem occurs. It seems that some dependent files were not packaged when installing the Macast (because I haven't maintained the Macast for a while, so I'm not particularly sure what the problem is). I expect to take the time to rewrite the code related to web pages around the beginning of next year.

bogie commented 1 year ago

Apparently the AUR targets the dev branch, which has split up the service and settings server. See https://github.com/xfangfang/Macast/blob/8f9d99d9b4b22622aff31596d796c8f288582568/macast/server.py#L220

instead of listening on 0.0.0.0, the settings server is forced on localhost, this should be at least configurable.

pyxdtc commented 1 year ago

xml/setting.html add this:

2017fighting commented 2 months ago

maybe macast-gui.bin does not exist now, what should i change it to ?