Play Videos multiple times in unity
We are developing augment reality cloud based sdk...so we want to detect image feature and play video content of the image....it's very well working in android..but when will we deploy to ios ,the video play multiple times,We are not familiar with ios......
This is my code....
using UnityEngine; using UnityEngine.UI; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using System; using System.IO; using System.Text;using System.Threading; using System.Text.RegularExpressions; using System.Collections; using System.Collections.Generic; using System.Net;using System.Net.NetworkInformation; public class CamTest: MonoBehaviour {
private bool camAvailable; private Texture greenlaser; /////private Texture errmsg; //[SerializeField] //Animator anim; private int ll = 0; private WebCamTexture backCam; private Texture defaultBackground; public RawImage backGround; public AspectRatioFitter fit; Texture2D snap;
public string Ddf;
private float k=0; private float k1=0; private float k2=0; private int cls=0;private float k5=0;
private int ta = 0;
string texturl;
public void Start()
{
defaultBackground = backGround.texture;
WebCamDevice[] devices = WebCamTexture.devices;
if (devices.Length == 0)
{
Debug.Log("No Camera Detected");
camAvailable = false;
return;
}
for (int i = 0; i < devices.Length; i++)
{
print("Webcam available: " + devices[i].name);
if (!devices[i].isFrontFacing)
{
backCam = new WebCamTexture(devices[i].name, 320, 240);
}
}
if (backCam == null)
{
Debug.Log("Unable to find Back camera");
return;
}
backCam.Play();
//backgram
backGround.texture = backCam;
camAvailable = true;
private void Update ()
{
StartCoroutine (Fade ());
if (!camAvailable)
return;
float ratio = (float)backCam.width / (float)backCam.height;
fit.aspectRatio = ratio;
float ScaleY = backCam.videoVerticallyMirrored ? -1f : 1f;
backGround.rectTransform.localScale = new Vector3 (1f, ScaleY, 1f);
int orient = -backCam.videoRotationAngle;
backGround.rectTransform.localEulerAngles = new Vector3 (0, 0, orient);
k++;
}
public IEnumerator Fade()
{
yield return new WaitForSeconds (2f);
Destroy (snap);
snap = new Texture2D((backCam.width),(backCam.height),TextureFormat.RGB24,true);
snap.SetPixels(backCam.GetPixels());
//snap.ReadPixels(new Rect(0, 0, 640, 480), 0, 0);
byte[] bytes = snap.EncodeToJPG();
Destroy(snap);// Destroy(snap);
string base64s = Convert.ToBase64String (bytes);
Debug.Log (backCam.width + "-----" + backCam.height);
string url = "https://www.atlasar.com:449/";
string customUrl = url + "WebForm1.aspx";
// Debug.Log(tables1);
WWWForm form = new WWWForm();
form.AddField ("usd", base64s);
form.AddField ("tables", "targettable");
form.AddField ("phno", "9998877555");
WWW www = new WWW(customUrl, form);
yield return StartCoroutine (WaitForRequest (www));
Destroy (snap);
}
public IEnumerator WaitForRequest(WWW www)
{//Thread.Sleep (100);
yield return www; if (www.error == null)
{
Ddf = www.text;Debug.Log (Ddf);
if (Ddf != null) k2=1;
Handheld.PlayFullScreenMovie (Ddf);
//SceneManager.LoadScene ("onlygame", LoadSceneMode.Single);
}
else
{
Debug.Log("WWW Error: " + www.error);
}
yield return new WaitForSeconds(.3f);
} }
if anyone know about this issue pls let me help...Thanks..Sorry my bad english....i am not a native english speaker..
Your answer
Follow this Question
Related Questions
Calling coroutine in a method issue. 1 Answer
Webcam not streaming on Unity3D windows 0 Answers
Unet load testing 0 Answers
There is an error with onEndEdit with the inputfield 1 Answer