Unity3d playing video in OGV format

Source: Internet
Author: User

HTTP://PAN.BAIDU.COM/S/1DDZZMDR, the converter will convert other formats into the OGV format, directly recognized by unity, no need to install QuickTime does not need to restart, more importantly than the MOV into unity to be clear.

[CSharp]View Plaincopy
  1. Using Unityengine;
  2. Using System.Collections;
  3. Public class Movietest:monobehaviour
  4. {
  5. //Movie Textures
  6. Public movietexture Movtexture;
  7. void Start ()
  8. {
  9. //Set the main texture of the current object as the movie texture
  10. Renderer.material.mainTexture = movtexture;
  11. //Set movie texture playback mode to loop
  12. Movtexture.loop = true;
  13. //startcoroutine (Downloadmovie ());
  14. }
  15. void Ongui ()
  16. {
  17. if (Guilayout.button ("play/Continue"))
  18. {
  19. / /play/continue playing video
  20. if (!movtexture.isplaying)
  21. {
  22. Movtexture.play ();
  23. }
  24. }
  25. if (Guilayout.button ("pause playback"))
  26. {
  27. //Pause playback
  28. Movtexture.pause ();
  29. }
  30. if (Guilayout.button ("Stop playing"))
  31. {
  32. //Stop playing
  33. Movtexture.stop ();
  34. }
  35. }
  36. IEnumerator Downloadmovie ()
  37. {
  38. www www = new www ("http://127.0.0.1/Head.ogv");
  39. Yield return www;
  40. Debug.Log (Time.time);
  41. Movtexture = Www.movie;
  42. //Set the main texture of the current object as the movie texture
  43. Renderer.material.mainTexture = movtexture;
  44. Movtexture.loop = true;
  45. }
  46. }

Plus sound

[CSharp]View Plaincopy
  1. Using Unityengine;
  2. Using System.Collections;
  3. Public class Movietest:monobehaviour
  4. {
  5. //Movie Textures
  6. Public movietexture Movtexture;
  7. //Sound
  8. Public Audiosource Movaudio;
  9. void Start ()
  10. {
  11. //Set the main texture of the current object as the movie texture
  12. Renderer.material.mainTexture = movtexture;
  13. //Set movie texture playback mode to loop
  14. Movtexture.loop = true;
  15. //startcoroutine (Downloadmovie ());
  16. }
  17. void Ongui ()
  18. {
  19. if (Guilayout.button ("play/Continue"))
  20. {
  21. / /play/continue playing video
  22. if (!movtexture.isplaying)
  23. {
  24. Movtexture.play ();
  25. Movaudio.play ();
  26. }
  27. }
  28. if (Guilayout.button ("pause playback"))
  29. {
  30. //Pause playback
  31. Movtexture.pause ();
  32. Movaudio.pause ();
  33. }
  34. if (Guilayout.button ("Stop playing"))
  35. {
  36. //Stop playing
  37. Movtexture.stop ();
  38. Movaudio.stop ();
  39. }
  40. }
  41. IEnumerator Downloadmovie ()
  42. {
  43. www www = new www ("http://127.0.0.1/Head.ogv");
  44. Yield return www;
  45. Debug.Log (Time.time);
  46. Movtexture = Www.movie;
  47. //Set the main texture of the current object as the movie texture
  48. Renderer.material.mainTexture = movtexture;
  49. Movtexture.loop = true;
  50. }
  51. }


Note: 1280*720 resolution of video played in this way does not produce black edges.

Unity3d playing video in OGV format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.