0

Sorry I'm completely new to Unity so I'm probably asking a stupid question. How would I play a video content from a different computer? I know that I would have to establish the remote access connection to access the specific video file located in another computer and then use the filepath of the stored video as the sourcepath to play the video from.

I guess I'm not really sure of which function to use in Unity exactly. I saw posts about movietexture function in unity, but is there any other way or can I just pass in the filepath parameter to movietexture and it will automatically start playing from the source path? Thanks

Programmer
  • 121,791
  • 22
  • 236
  • 328
Mark Jackson
  • 75
  • 1
  • 2
  • 10
  • Will the Unity App be running on both computers or just the computer that is playing the video? – Programmer Mar 15 '17 at 18:39
  • Just the computer that will play the video. So I have a computer with Ubuntu 16.04 OS installed and have all the video files stored there. I have another computer with Windows OS and Unity is running inside Windows. So I have to access the videos from the Ubuntu OS – Mark Jackson Mar 15 '17 at 18:43
  • I'm also using Unity Personal Edition and don't have the Pro edition – Mark Jackson Mar 15 '17 at 18:44

1 Answers1

0

After reading your comment, it looks like all you have to do is share the folder that contains the videos file in Ubuntu. This is how you Share the folder.

Usually to access a network file, you use double backlash followed by the computer name then the file directory.

\\computername\filepath\videofilename.mp4

To use this in a code you have to escape the \ by adding another one in front of it. One \ becomes \\ and two \\ becomes \\\\.

The url to use in your code should look something like this:

"\\\\servername\\filepath\\videofilename.mp4"

This post describes is how to play video in Unity. You have to download Unity 5.6 before you can use that.

Get the script then replace:

videoPlayer.source = VideoSource.VideoClip;

with:

videoPlayer.source = VideoSource.Url;
videoPlayer.url = "\\\\servername\\filepath\\videofilename.mp4";
Community
  • 1
  • 1
Programmer
  • 121,791
  • 22
  • 236
  • 328
  • thank you so much. one thing i forgot to ask is for the filepath, what if i have something like /usr/home/video where / is used. do i turn all the / to \? basically do i use \ all the time? – Mark Jackson Mar 15 '17 at 19:30
  • try the backlash first, if that doesn't work then use the forward slash. I haven't used Ubuntu before. I do this on Windows but it should work. Let me know which one works for you. – Programmer Mar 15 '17 at 19:33
  • Thanks. My final question is can I automatically run a php script inside unity's C# without opening the php script in the web browser? I have seen a video tutorial where the wamp stack is set up in windows and the php file from the stack's www folder is being run in the web page and then inside unity's C# script, IEnumerator and WWW form class is used to 'download' the php script and the data from the php file. Can I just automatically execute the php script from inside Unity's C# script using the php script's filepath inside WAMP's www as the source without opening the script in a web browser – Mark Jackson Mar 15 '17 at 20:08
  • That's a complicated question. Why do you need to run php code in Unity? – Programmer Mar 15 '17 at 20:13
  • so i want to store all the filepaths in mysql database inside ubuntu and in windows, i want to use the php script to access all the filepaths, and choose a filepath from php and use that filepath to play a video in unity – Mark Jackson Mar 15 '17 at 21:33
  • Run the php on the ubuntu not inside Unity. Now, you can commucate with the php with C# from Unity with the WWW class. You may also want to use Json to store all the video information such as url, length, name. This is how to use [`WWW`](http://stackoverflow.com/a/42275719/3785314). Please Google Php and Unity WWW and you will get more information. – Programmer Mar 15 '17 at 21:40
  • OK i started this method initially and accessed the php inside unity directly from ubuntu's ip address but even inside Ubuntu, I had to run the Wamp stack and run the php script in web browser. So there's no way to like skip the manual opening of the php script in the web browser? – Mark Jackson Mar 15 '17 at 21:45
  • You don't need a webbroswer for this. The only time you that is to test if your php server is working properly. You can use Unity's WWW class to connect to the php server and retrieve information from it – Programmer Mar 15 '17 at 21:47
  • thank you so much it finally makes sense lol. so I dont even have to manually start the wamp stack in ubuntu every time right? – Mark Jackson Mar 15 '17 at 21:49
  • Your server must be running before you can use it, right? Start the server then leave it alone. If your computer re-starts, there is a way to make programs automatically restart on Windows. I think you can also do so on Ubuntu. Make the server automatically start when system reboots. – Programmer Mar 15 '17 at 21:51
  • ok yup i was thinking about automatic bootup as well. thank you so much and I'm sorry for bothering yu like this lol. I didn't take any networking class and brand new to unity and C# in general so yu have helped me tremendoulsy – Mark Jackson Mar 15 '17 at 21:54
  • Sorry for disturbing again. I think saying sorry is becoming more common in this thread lol. I tried this in 5.6 Beta but unfortunately I have to use 5.5.1f1 version of Unity and I noticed on the documentation, the same VideoPlayer class is not present. The MovieTexture class is there but its for Unity Pro edition. Is there a video class thats available for the Personal edition of Unity? Man I wanted to do direct MySql access from Unity by importing the MySql.Data dll from .Net 6.9 connector but Unity doesn't recognize the dll at all and I needed this Dll to use the built-in functions for db – Mark Jackson Mar 16 '17 at 02:07