- Home /
Adding an array from a local folder of videoclips to the videoplayer
Hello, I have just solved one problem to encounter another as I am not well versed on unity at all. What I am after is, I am trying to get my application on Unity to load a bunch of videos files on awake onto the video player. I am able to get the files using this function.
string[] files = System.IO.Directory.GetFiles( path );
My question is, how to you need add the data from the path to an array of video clips that then reference the video player so they will be played on awake and cycle through?
Again apologises for the lack of code, I am just not sure where to even start. I had tried
videoPlayer.url = ("C:/Users/Anthony/Desktop/VReditor40221587/Videos/Shatner.mp4");
however it only plays that specific clip!
Does anyone have any experience with this? Thanks in advance.
Answer by xxmariofer · Jul 28, 2019 at 07:44 PM
before gonig into a harder solution, are there any needs why you need to find the videos by link? cant you just create an array of VideoClips public, drag and drop all the videoclips to that array, and just simply use the clip property?
videoPlayer.clip = arrayOfClips[0];
then you just need to change the index of the array to fire the other videoclip whenever you want with some method or condition
That was my original idea, I had a videoclip array and I just dragged and dropped them into the inspector from the assets folder and the app just cycled through them. However this app I am developing has stipulated that I must retrieve videos from a local folder and have app load them into an array upon load but I've searched around and dont seem to see any solution to it.
well the idea of the array of string you called files is basically the same, that array should have all the files in that directory, and you can just iterate over him or i am missing something?
videoPlayer.url =files[0];//Or any other index
Ah right yes that did the trick. $$anonymous$$any many thanks!