Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by gcscreations · Apr 07, 2018 at 05:16 AM · unity 5webcamtexturecoroutine errors

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..

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

210 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Master Audio source volume control with slider 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges