Download or Stream Video
Hello, is there a way to make a menu where the user can decide to download a video to the phone (Using memory of iphone for example) or stream from the web? Regards
First, work out two seperate functions. One will download the video and play it. The other will play the video by strea$$anonymous$$g it.
From there, its as simple as showing the user a UI with two buttons, and depending upon which button is clicked, call the appropriate function.
Thank you! Do you have any idea how can i make that code, im trying that for 2 weeks and nothing :( Regards
You'll want to use the WWW class for getting the file or stream. I'll show you how to get the file or stream, but what to do with it after that is up to you, as I haven't worked with video files in Unity.
public IEnumerator DownloadFile(string url)
{
var www = new WWW(url);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
var filebytes = www.bytes;
$$anonymous$$emoryStream stream = new $$anonymous$$emoryStream(filebytes);
}
else
{
Debug.Log(string.Format("An error occurred while downloading the file: {0}", www.error));
}
}
This is the method that you can use to download the file, and I provided the line that converts it into a $$anonymous$$emoryStream.
Yes, but you can try this website which easy download your facebook video in a sec
https://fvdtube.com/facebook-video-downloader/
Follow Simple Step:-
Step 1: Login Facebook.com.
Step 2: Select the video you want to download & select show url.
Step 3: Copy the url of the video you want to download.
Step 4: Open our facebook downloader tool & paste the link in text box.
Step 5: Select download button. it will give you two choices “Download SD” & “Download HD”.
Step 6: Select the option of your choice. All done.
If you want to download videos from Twitter then you can use Twitter Video Downloader its easy and free. You will be able to download your video in few steps.
Answer by faizidp · Jan 20, 2018 at 11:06 PM
Yes you can! You can use UnityWebRequest or WWW to download the video from web URL in the form of bytes in persistent Data Path. And then use that path as value of "URL" in VideoPlayer component introduced in recent version of Unity (2017.1 I guess).
For Downloading the video:
IEnumerator testVideoDownload(){
var www = new WWW ("http://clips.vorwaerts-gmbh.de/VfE_html5.mp4");
Debug.Log ("Downloading!");
yield return www;
File.WriteAllBytes(Application.persistentDataPath+"/videoFile.mp4",www.bytes);
Debug.Log ("File Saved!");
}
Setting Up Video Player
Create a Quad. Add VideoPlayer component to it. Choose Source to URL. Set "Play On Awake" to false.
Script for Video Player to Play the video.
using UnityEngine.Video; //Make sure to add this
.
.
public GameObject VideoPlayerGO;
VideoPlayer video Player;
void Awake(){
videoPlayer=VideoPlayerGO.GetComponent<VideoPlayer>();
}
void Start(){
PlayVideo("videoFile.mp4");
}
void PlayVideo(string fileName){
videoPlayer.source = Application.persistentDataPath + fileName;
videoPlayer.Play();
}
Answer by Mayank516 · Jan 24 at 06:53 PM
I have used following plugins for streaming in iOS :
To Stream audio: https://assetstore.unity.com/packages/tools/audio/audio-stream-in-ios-182585
To Stream Video : https://assetstore.unity.com/packages/tools/integration/video-streaming-in-ios-98645
Your answer
Follow this Question
Related Questions
Video Player and Web GL build not working 2 Answers
Loading from streaming assets in obb fails.. but not always. 1 Answer
Path to streamingassets obb video 0 Answers
Video Streaming with New Unity Video Player issue 0 Answers
How do i make a certian video play if I shoot at a certian position on my map 2 Answers