How to access files from other local disk?

I have a function imported from npm that’ll open VLC media player given a path of a video file as its argument. It works fine for relative file paths. But, when I pass it a path like D:/some_video.mp4, it doesn’t work. The docs says it’ll accept a string path to a video file.
How to fix this?

Code:

let VLC = require('vlc-simple-player');
let path = "./1x01 Pilot.avi";

//Start a fullscreen player
let player  = new VLC(path, {arguments: ['--fullscreen', '--no-video-title']});

// Close the player after the video has 'stopped'
player.on('statuschange', (error, status) => {
  if (status.state == 'stopped') player.quit();
});

This script is in local disk (C:) and I can give a path relative to this. What if I wanted to play some file that’s in local disk (D:)?

Hello, skanda.

We would need more information, in order to help you. Would you be able to post your code?

I have included the code in the description.

If you have to use a relative path, then you could do something like:

// Path to script: C:/somefolder/script.js
// Path to video: D:/anotherfolder/video.mp4

let path = '../../D:/anotherfolder/video.mp4';

Hope that helps

It’s not working. I tried exactly like you said.

Well, copy-pasting exactly what I said would definitely not work. I do not know what your working directory looks like. If you want more help, you will have to copy the full path to your workspace (where your Javascript file is), and the full path to the video you want opened. Then, I would be able to help.

Of course, I did not copy-paste. I used the same pattern for file locations indicated in your example.
Script location: C:\Users\skand\OneDrive\Desktop\vlc\vlc_cli.js
Video location: D:\1x01 Pilot.avi

Then, this should work:

let path = '../../../../../../D/1x01 Pilot.avi';

It didn’t work. I also tried with a colon next to D (D:) like in your first example and it didn’t work either.
So, may be the function don’t support these kinds of file paths?

What errors do you get?

It opens up the player and closes it immediately. No errors. I think it doesn’t accept files from other disks.

Does this work?

const path = 'D:\\1x01 Pilot.avi'

It works for me using absolute paths.

Yes, it works. Thanks.
Why did it work? Because of the forward slashes instead of backslash?

Yes and one of the slashes is an escape.

You want this "D:\1x01 Pilot.avi", but you have to escape the slash, so it becomes this "D:\\1x01 Pilot.avi"