vlc-rpc / vlc-discord-rpc

Display what you're watching on VLC media player as your Discord status with this Node.js application.
MIT License
43 stars 14 forks source link

[BUG] Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'category') when trying to launch with "node ." Seems it can't connect to VLC despite having followed the steps. #12

Closed LKDev-Tech closed 6 months ago

LKDev-Tech commented 6 months ago

So I'm trying to watch a video I got saved on my computer and it doesn't have any metadata as far as I know since this is the error that keeps coming up. (the one in the title, trying to read category when that field is empty probably or smth)

So I tried running the rich presence app without anything open in VLC and I still get this error. I checked the vlcPath in the config file and it is the correct path to my custom VLC install folder but it doesn't seem to be able to communicate with it for some reason. In the main interfaces on VLC, I have

In Lua interpreter I have these settings (I double checked and I have the same password on both config and VLC) in case I somehow messed up, I changed the password to a simple one like 123 in both places and still get the error even tho VLC is running and has a video playing. Oh and I set detached to true

Connecting to Discord...
Logged in as *************************
Failed to reach VLC. Is it open?
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'category')
    at module.exports (h:\Discord\vlc-discord-rpc-main\Functions\rpc-format.js:23:35)
    at <anonymous> (h:\Discord\vlc-discord-rpc-main\Functions\client.js:28:41)
    at module.exports (h:\Discord\vlc-discord-rpc-main\Functions\status.js:85:7)
    at processTicksAndRejections (internal/process/task_queues:95:5)

I went to status.js in the Functions folder and it dies on line 21 where it tries to await VLCClient.getStatus(); first goes here when I step into image line 57 step into that then get here image line 57 pass the return new Promise gets the address var, everything seems fine runs _request on line 59 drop to line 97 starts doing that promise passes data, basicAuth and we get to req on req it does the http.get(address.toString()) thing but instead of .on('response' it jumps to .on('error', reject) and then the usual output of Failed to reach VLC. blah blah comes up and exits.

Not sure what the issue is I followed all the steps one by one and precisely. The only thing I didn't fill out was the spotify information because I don't have an account and don't use it and don't really care about the cover pictures. Unless filling out the spotify information is an essential part to fill out in the config?

Lauren1066 commented 6 months ago

Yes, it will not work unless you fill out the spotify information, which I can fix in a later update. However, that does not seem to be the cause of your issue. It's not reaching VLC. Does it work in the attached state? I had a lot of trouble setting up the detached state myself, to be entirely honest. It may be a code issue, although I was able to get mine to work before merging the PR, but I also had the default VLC location. There are a lot of factors that go into the code.

Lauren1066 commented 6 months ago

Now optional in https://github.com/vlc-rpc/vlc-discord-rpc/pull/13

Lauren1066 commented 6 months ago

I am able to reproduce this. I will continue to look into the issue.

Lauren1066 commented 6 months ago

I was able to fix this issue.

const vlcConfig = {
  password: "123",
  port: 8080,
  address: "localhost",
};

Here is my config.js information.

Here are my vlc options: image image

8080 is the default port for VLC HTTP stuff. Looks like I was looking at the wrong box when making the README.

Let me know if you are able to get it to work.

https://github.com/vlc-rpc/vlc-discord-rpc/commit/b5689a390bf4ce3e57a3ac2340deedde3bd71366

LKDev-Tech commented 6 months ago

Ok just tested in the attached state and it works fine no issues.

Now I tested the detached state and... image This keeping in mind I downloaded the latest version of the repo, deleted the old folder and extracted everything, changed all the settings in both VLC and the config file.

As stated, attached works fine, detached gives me the error above... I'll be using attached for now but it would be great to find out wtf is up with detached and my computer lol

Ok so after more testing, that error only comes up when VLC is open and no video or music is in the queue. If there's something in the queue, then it works as intended and no issues in detached state.

One more thing, I'm trying to set my own custom image as the largeImageKey and it's not taking the image saved on my computer, does it have to be a link or am I missing something to make it work?

Thanks

Lauren1066 commented 6 months ago

Yes, I believe it needs to be a link to work. You can upload it to imgur or something like we did, or put it as any accessible link that ends in .png, .jpg, or something of that sort. In a future commit I will attempt to allow local files. I will try to fix the issue where it errors if nothing is queued, which will likely just be a message telling you to queue something before running it. I will also add a note about both things in the read me. I apologize for my poor documentation, I am updating it as issues arise.

I appreciate all your feedback! I did not think about a lot of these things to be entirely honest.

LKDev-Tech commented 6 months ago

No problem Happy to help. in my personal unsolicited opinion, I think there should always be some level forward thinking about some features and the various ways they could be implemented.

Such as the Spotify thing being mandatory when it could've been optional in case someone doesn't have an account or doesn't want to link it etc.

Since this is a project I assume you make no money on and is just something for fun, I can understand not really thinking about some things in advance lol.

Lauren1066 commented 6 months ago

I'm looking into the detached issue with no queue, and I'm currently unable to reproduce. For me, on the current branch I just get VLC not playing; going to sleep. true. I assumed it would fail, because I saw that same output many times yesterday, but it seems to work on my end. Did you touch the port number at all? My config is the same as yesterday.

As for not making money, yeah I don't make anything. Just started this as a way to help someone out, since the old repo was not working I told them I'd try and fix it.

If there's ever any suggestions I'm open to it!

LKDev-Tech commented 6 months ago

nvm detached with no queue works now I didn't change anything so idk what the issue was but seems ok now.

Lauren1066 commented 6 months ago

Okay let me know if there's any more issues.

I updated the README.

1) There is an option to use files now, though not locally. I'm not sure if it's possible to do local due to how rich presence works. 2) Added a link to our discord 3) Added a note about the queue, which I think I can safely remove now.

Lauren1066 commented 6 months ago

Closing this as all issues seem to be resolved. Open a new issue if needed.