playMaker

Author Topic: How to get relative filepath for videos  (Read 578 times)

TimD

  • Playmaker Newbie
  • *
  • Posts: 3
How to get relative filepath for videos
« on: May 02, 2021, 10:50:12 AM »
Hi, I am making a simple video player and want to load in an play videos in a folder relative to the final build.

So, I will have the final .exe / mac package, with a folder in the same directory as this which contains the videos.

Couple of questions...

1) how do I get the current directory of the main app/build and set as a variable, so I can use this to create the file locations of the external videos? (ie. getting the application folder)

2) Is there a way to list the files in a folder and put them into an array - (so I could ultimately parse through these like a playlist)

I came across this thread, but the actions don't seem to be in the ecoSystem - https://hutonggames.com/playmakerforum/index.php?topic=11861.msg55579#msg55579

Thanks :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to get relative filepath for videos
« Reply #1 on: May 03, 2021, 07:56:16 AM »
Hi.
There is some issue on the Ecosystem at the moment.

but on the thread you can download the .cs file and place in our project.

but maybe this asset would be easier :

https://assetstore.unity.com/packages/tools/gui/runtime-file-browser-113006

i made some actions for '600' a while back i will look if i can find then and ask '600' if i can share them

TimD

  • Playmaker Newbie
  • *
  • Posts: 3
Re: How to get relative filepath for videos
« Reply #2 on: May 03, 2021, 01:26:30 PM »
Hi.

So i think I've managed to write a custom script!! But please can someone check it's actually right as I'm pretty new to all this!  ;D

https://imgur.com/a/9XZZnd6

It creates an array of all the files within a specified folder, and also lets you add a filetype filter (So *.* is all files, *.mp4 is mp4 videos etc...)

I also added a check box to automatically start the folder path with the current location of the unity app - so in my case, looking for files in a folder called 'vids' that's in the same root as the main app, I just check the box and add '/vids' as the folder path.
'/' will look in the application path root.

(The target array variable will need to be an array of type string)

I've attached the .cs file.

Tim :)
« Last Edit: May 03, 2021, 01:52:01 PM by TimD »