I’m trying to create a video player that can play and skip tracks using an index of clips. My current code creates fields for the index to drop in video clips. Originally this worked when using video clips, but now I need to access the clips via URL. This is the code I have. Now, however, I need to switch the index to one that supports URLS.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Video;
I have the videos uploaded on Github, Usually it would work when switching the source to URL and adding the URL in the URL field in the built-in video player, but as it’s an index of URLs I’m looking to create rather than having just one single video, i’m not sure how to go about this.
Correct, don’t use an array yet. Just create a separate example that simply plays a single video URL. What is the URL? And you said “usually it would work”, please provide the code that was working for you. Once you get a simple example working, then implement an array of URLs https://docs.unity3d.com/Manual/Video.html
The creating an array of URLs is what I’m struggling with, as I haven’t ever done this. Like I said, previously it worked within the built-in video player where you just add in the URL as the source, so there was no need for me to write any code myself which is why I do not have any code to show. But this was for a single video. Now i have multiple videos on github that I’d like to index: https://siennakei.github.io/ATVideos/
This is where they are stored.
Writing code for an array of URLs is where i need help with.
Do you have an example with a SINGLE URL working via script, without an array? If you don’t have that working, an array won’t work either obviously. My suggestion is to get the basics working first. The URL you provided does not launch a video for me, please provide the exact URL you are using. Does it work when you enter it in the Inspector? Great! Now do the same thing via script with a single video. THEN work on the array problem.
I don’t have a script that uses URL’s as the source. My existing code uses video clips as the array:
public VideoClip.[ ] videoclips;
private VideoPlayer videoplayer;
private int videoClipIndex;
private void Awake()
{
videoplayer = GetComponent();
}
void Start()
{
videoplayer.clip = videoclips[0];
}
I just thought there might be a simple way to convert this existing code from video clips to URL’s as the source.
The link i provided was for the folder containing all videos, but for example here is a single video:
So I already have the video player set up with indexing, i just need to change the source from video clips to URLs in the above code. One single URL works fine in the built-in player, but for many, obviously i need to edit the code I have.
You say if it works in the inspector, then great, do the same in script, but this is what I’m struggling with
I have tried changing the videoPlayer to VideoPlayer.Url but i keep getting an error message.