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
2
Question by cregox · Feb 17, 2012 at 10:13 PM · videomoviebundlehandheld

Bundle up a movie file for handheld

From what I understand, currently (as of 3.5 beta) we can only play movies in iPhone / Android that are inside Assets/StreamingAssets or directly from a URL.

I want to be able to stream the video from a URL while caching it up, like in a bundle. Or at very least just be able to download the bundle so every time I play the movie after the first time it will already be local. Is this possible?

When I try to build the bundle (just like we already do for many different assets) I get a dreaded `'MovieTexture' is not supported when building for Android.`. Though I haven't tried it on iPhone build yet, I bet it'd be the same.

Comment
Add comment · Show 3
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 matrix211v1 · Feb 29, 2012 at 02:47 AM 0
Share

Any luck with this? I am trying to do the same thing.

avatar image cregox · Feb 29, 2012 at 11:53 AM 0
Share

Unfortunately, nothing yet, @matrix dude

avatar image cregox · Apr 09, 2013 at 06:28 PM 0
Share

There you go, @matrix211v1 - the answer has been posted quite a while ago.

2 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by cregox · Jan 14, 2013 at 11:11 AM

Can't remember exactly when or how Leandro got to this solution.

Basically, use `www` to download, then `Handheld.PlayFullScreenMovie` to play. With a magical setting on iPhone:

 private Color bgColor = Color.black;
 private FullScreenMovieControlMode controlMode = FullScreenMovieControlMode.Full;
 private FullScreenMovieScalingMode scalingMode = FullScreenMovieScalingMode.AspectFill;

 private string videoFile = Application.persistentDataPath + "/your-video-file.mp4";

 IEnumerator DownloadAndPlayVideo () {
   string playVideoFile = videoFile;
   #if UNITY_IPHONE
     playVideoFile = "file://" + videoFile;
   #end if

   WWW www = new WWW("http://www.example.com/video.mp4");
   yield return www;

   if (www != null && www.isDone && www.error == null) {
     FileStream stream = new FileStream(videoFile, FileMode.Create);
     stream.Write(www.bytes, 0, www.bytes.Length);
     stream.Close();
   }

   Handheld.PlayFullScreenMovie(playVideoFile, bgColor, controlMode, scalingMode);
 }

As the playing part implies, this is for handhelds only. It won't work anywhere else. Though we'd "just" need to replace Handheld with MovieTexture, AudioSource and maybe yet another www (haven't tested if it'd work with same one).

Comment
Add comment · Show 6 · 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
avatar image bWard · Mar 13, 2014 at 08:19 PM 1
Share

This solution works for me. To check if you've already downloaded the file, use System.IO.File. If it's true, you don't need to download and can skip straight to video playback.

 System.IO.File.Exists(videoFile);

avatar image Leon700 bWard · Sep 20, 2016 at 07:36 PM 0
Share

For some reason File.Exist was always returning true to me so i used:

         using System.Linq;

         string[] files = Directory.GetFiles(Application.persistentDataPath);
 
         if (files.Contains(playVideoFile)) 
         {
 
         }

Just in case someone else runs into this problem... And thanks for this Awesome code <3

avatar image cregox · Mar 14, 2014 at 02:12 AM 0
Share

That's right @bWard. I don't want to post the whole thing here else it gets too big, but there are many things that can be done to optimize it! ;-)

avatar image Stonegun · Mar 31, 2014 at 02:28 AM 0
Share

it helps to me , thanks :)

avatar image sathieswar · Aug 01, 2017 at 07:00 PM 0
Share

Thanks a lot :) Saved my Day :)

avatar image Futurristic · Feb 24, 2020 at 06:38 PM 0
Share

Its work for me thanks :)

avatar image
0

Answer by DVFrance · Jan 14, 2013 at 10:16 AM

Hi,

I'm trying to play a video on android to, as I read we need to use this :

Handheld.PlayFullScreenMovie

But for me it still not work so if you found a way ...

Comment
Add comment · Show 3 · 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
avatar image cregox · Jan 14, 2013 at 11:11 AM 0
Share

Yes, we've found a way... $$anonymous$$eanwhile, this is far from being an answer, although it's the same path we went to indeed. Any way, you should change this to a simple comment! ;-)

avatar image DVFrance · Jan 28, 2013 at 09:52 AM 0
Share

Hi Cawas and tks for your answer.

I tried this but I still can't play the video, I have no error, no warning, the scene run but the video still not play.

I maybe found a way with this Universal_Video_Texture_LITE but I didn't try it yet. I'll tell you what going on :)

avatar image cregox · Apr 09, 2013 at 06:34 PM 0
Share

Back from vacations, @awesomealex ! I haven't posted a whole functioning script there. Just pointers on how to do it. Probably you did something wrong along the way... You could try posting a new question about it and link to it from here, so I can see it. But I assure you there's no need of anything but Unity to make it work. No addons or plugins what so ever.

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

13 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

Related Questions

How to check if Handheld.PlayFullScreenMovie has stopped playing 2 Answers

PlayFullScreenMovie bug... 0 Answers

Video won't play in exported game? 3 Answers

Unity 5.6 videoplayer: How to get the total length of a video? 2 Answers

Does www.movie acccept .ogv files? 2 Answers


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