- Home /
Remote Desktop in Unity3D: How to setup VLC(?) and Unity?
Hello there :),
I want to stream a remote Desktop into a Unity Game Application. Using VLC seemed the best option as it allows live capturing of the desktop and streaming it via network.
However it appears Unity is only capable of playing an OGG-File, which is completely ready to be played (I mean, a Video-Stream like from VLC constantly extends a video file).
Hence I wonder, how do I stream a remote desktop to Unity. Is VLC really the best option? How do I have to setup VLC? Can I use the attached script to achieve it?
PS: JavaScript and C++ are both OK, only the example is in JS.
Thank you all for your help!
var url = "http://mydomain/liveFeed.ogg";
function OnMouseDown(){
var www = new WWW(url);
var movieTexture = www.movie;
while(!movieTexture.isReadyToPlay) yield;
// Initialize texture to be 1:1 resolution
renderer.material.mainTexture = movieTexture;
// Assign clip to audio source
// Sync playback with audio
audio.clip = movieTexture.audioClip;
// Play both movie & sound
movieTexture.Play();
audio.Play();
}
Answer by tbreina · Dec 26, 2013 at 04:25 AM
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(AudioSource))]
public class stream : MonoBehaviour
{
public WWW wwwData;
public string url = "http://localhost:8080/";
private MovieTexture m;
void Start ()
{
wwwData = new WWW (url);
m = wwwData.movie;
}
void Update ()
{
renderer.material.mainTexture = m as MovieTexture;
// audio.clip = m.audioClip;
if (!m.isPlaying) {
m.Play ();
audio.Play ();
}
}
}
I tried this and it works for Unity 4.3.1f1. The only problem I have is that if I uncomment the audio.clip = m.audioClip; then the movie plays the audio but the video is just the first frame. If I keep the audio clip out, then it plays the video smoothly.
So right now this code will either do the audio or the video but not both.
-Tony