Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
3
Question by quantum_rez · Jan 10, 2013 at 02:40 PM · androidtexturevideomovie

how to play video on android

hello guys, i need help here. i want to play video on my android device, i already use many way to achieve that, but no success at all.

this the way i already try :


 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(AudioSource))]
 [RequireComponent(typeof(AudioListener))]
 
 public class Movie : MonoBehaviour {
 
     public MovieTexture movie;
 
     private float movieTimer;
 
     void OnGUI(){
        GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), movie);
        movie.Play();
 
        if(movie.duration < movieTimer){
          movie.Stop();
          print("Movie Finish");
        }
     }
 
     // Use this for initialization
     void Start () {
 
     }
 
     // Update is called once per frame
     void Update () {
        movieTimer += Time.deltaTime;
     }
 }

this don't work because android not support MovieTexture

  • void Start () { StartCoroutine(PlayMovie()); }

       protected IEnumerator PlayMovie(){
             
             Handheld.PlayFullScreenMovie("movie1.avi", Color.blue, FullScreenMovieControlMode.CancelOnInput);
             
             yield return new WaitForSeconds(2.0f);
             
             print ("Move Scene");
         }
    

My step : - create new C# script and use above code - create empty game object and then attach the script into game object

i don't know why this don't work, but the video not play


 IEnumerator Start()
 
     {
 
         Handheld.PlayFullScreenMovie("movie1.avi", Color.blue, FullScreenMovieControlMode.CancelOnInput);
         
         yield return null;
 
         print ("Move Scene");
 
     }

My step : + create new C# script and use above code + create empty game object and then attach the script into game object

this is the last one and not work too, i'm really confused why this code don't work..

Comment
Add comment · Show 8
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
avatar image quantum_rez · Jan 10, 2013 at 03:06 PM 0
Share

sorry it's already work, i made a mistake because use avi format not mp4, after i change into mp4 it's work..

but i have get some problem here, the video not played in full screen and before the video play there will be blank screen maybe 1 or 2 seconds.

anyone can help me to solve this? i used the second and third code both work properly but not full screen and have blank screen for 1 or 2 second..

Thanks before

avatar image Psymon · Jan 10, 2013 at 03:57 PM 0
Share

Where do you load your video ? In a new scene ? Is the scene empty ? Do you want a loading screen or a black screen ?

For the fullscreen thing : what is the resolution of the screen device and the resolution of your video ? In my experience the video doesn't stretch in order to fit the screen device.

avatar image quantum_rez · Jan 10, 2013 at 04:12 PM 0
Share

ya, i have 1 scene to play the movie and the name is $$anonymous$$ovie.scene.

in $$anonymous$$ovie.scene, i have camera and empty game object attach with $$anonymous$$ovie.cs, the code is :

void Start () { StartCoroutine(Play$$anonymous$$ovie()); }

 protected IEnumerator Play$$anonymous$$ovie(){
     
     Handheld.PlayFullScreen$$anonymous$$ovie("movie1.mp4", Color.blue, FullScreen$$anonymous$$ovieControl$$anonymous$$ode.Hidden);
     
     yield return new WaitForSeconds(1.0f);
     
     Application.LoadLevel("City");
 }

so the problem is, before the video play, i'll see background color that set by camera for maybe 1-2 seconds.

when the video play, not full screen so in left and right there will be a color that i set in parameter 2, in this case Color.blue.

my devices is Samsung galaxy wonder, and my video resolution is 640 x 480, can i make the resolution more than this?

sorry what's loading screen or black screen?

Thanks for your reply :D

avatar image Psymon · Jan 10, 2013 at 04:25 PM 0
Share

Your device has a 800x480 resolution so it's normal to have borders on the left and on the right. If you want a fullscreen on this specific device you must have a 800x480 video. But keep in $$anonymous$$d this particular resolution will not fit with other devices.

For the loading screen/black screen it was what you wanted. You can set the camera background in black in order to have a black screen before the video (or blue in order to fit with your movie). The loading screen is the same idea except you have to render an image in front of your camera. It's your choice actually.

I'm not sure but you'll not avoid the 1-2 seconds look on the scene because it's the time for the device to load your video. It can be faster with faster devices I guess.

avatar image quantum_rez · Jan 10, 2013 at 04:34 PM 0
Share

oh, i got it now, i think the video will fit to screen, but i'm wrong at all..

wow, that's a nice idea so just like loading before the video played, ok ok..

thanks for your reply it's really help me here, i'll try to change it and then give the result here :D

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by pratam13 · Dec 14, 2016 at 02:07 PM

hey can you help me ? Can you show a complete tutorial on video for android

Comment
Add comment · Share
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

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

14 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

Related Questions

why cannot build movie texture on android? 4 Answers

Movies on Android. Is it possible? 2 Answers

Movie/Video Texture 0 Answers

IphoneUtils.PlayMovie for Android 1 Answer

How to play a video clip on android device 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