Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video Unity 5.6.1: VideoPlayer.Play() or VideoPlayer.Prepare(); leads to temporary game freezes

Discussion in 'Audio & Video' started by Im-Berzki499, May 28, 2017.

  1. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    Hi, everyone!

    I'am using standard Unity VideoPlayer component.
    Unity version is 5.6.1.

    The problem is that the game freezes when I call VideoPlayer.Prepare(); or VideoPlayer.Play(); when trying to play video from URL. And resumes only when VideoPlayer operations are completed.

    the code is something like this:

    Code (CSharp):
    1. videoPlayer.url = url;
    2. videoPlayer.Play();   // <<<- Whole game freezes until this operation is completed. It's looks like VideoPlayer is downloading video in UI thread and blocking it.
    or this

    Code (CSharp):
    1.  
    2. videoPlayer.prepareCompleted += (source) =>
    3. {
    4.    source.Play ();
    5. }
    6. videoPlayer.url ="http://...";
    7. videoPlayer.Prepare(); // Freeze starts from this point.
    8.  
    Also, when I try to use VideoPlayer.Prepare(); method I've got the same - the game freezes until Prepare() is completed and playback is started. Looks like that this operations works at the same UI thread and blocking it;

    Is there any way to run VideoPlayer.Prepare() operation in another thread, or something like coroutine with it?

    Looks like it's Unity VideoPlayer bug or I missed something?

    Thanks in advance!
     
    Suraksha226 and taguados like this.
  2. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
  3. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    wesloc, thanks for your answer!

    Unfortunately, registering callback for prepareCompleted has no effect at all.
    As you can see from code listed above, I am already tried it.

    I cannot figure out the purpose of Prepare() method. With it's current behavior it's seems that there is no effect from it.

    Also I've tried this with Unity 2017.1.0.b7. Got the same result. And in additional got choppy video playback.

    Hope it's a bug which will be fixed soon. Or some workaround will be found.
     
  4. hellaeon

    hellaeon

    Joined:
    Jul 20, 2010
    Posts:
    90
    Right now, in the Editor it is fine, but when I build it to mobile, VideoPlayer.Prepare holds up the main thread.

    My next steps are to try to
    • preload the video on a separate thread
    • save it to the mobile device
    • load it into the video player
    upload_2017-5-29_10-33-53.png

    Once I can get something basic working, I will post it back here.

    Cheers
     
  5. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    • preload the video on a separate thread

    Good point. This could solve the problem. I will try it too.

    Thanks.
     
  6. hellaeon

    hellaeon

    Joined:
    Jul 20, 2010
    Posts:
    90
    I tried to preload in a separate thread, but the issue is squarely in VideoPlayer.Prepare().
    I can live with it for a prototype. Did I miss something though? You cant stream?

    Cheers
     
  7. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    Looks like it's a bug in VideoPlayer.Prepare().
    I didn't solved it too.
     
  8. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    Should we move this issue to the Unity Answer section? I thought that there are unity engineers monitoring the forum?
    We just want to know if we missed any step or this is a bug that will be addressed in the future.
     
  9. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    wesloc, I am agree with you. It's looks like that we need help from Unity developers.
     
  10. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    Maybe we can go open an Unity issue? I saw several related to Prepare() but none of them stated what we encounter clearly.
     
  11. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
  12. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    I don't know how to open new issue in unity bug tracker. Looks like I have no rights to do it.
    I've reported an issue using Unity Editor.
     
    Last edited: Jun 1, 2017
  13. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    Last edited: Jun 2, 2017
  14. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    @Im-Berzki499

    Thanks. I just voted it up!! In addition, do you think it's worth to repost this question in Unity Answer. Maybe, someone with more experiences can come up a work around since we do not know when Unity will fix the issue.
     
  15. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    I think It's good idea! We should use any possibility to solve this issue. It's serious blocker not just for us. I don't see anything wrong to ask for help. So, do it.

    Maybe someone who has acces to Unity source code can take a look on VideoPlayer.Prepare() implementation and make a guess or figure out what is wrong with it.

    Also, we can collaborate to solve this issue or to find some workaround.
     
  16. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    Any updates?
     
  17. paras_til

    paras_til

    Joined:
    Jun 23, 2017
    Posts:
    1
    Anyone able to solve this? I am facing the same issue on Android. For iOS and Desktop it works fine.
     
  18. Im-Berzki499

    Im-Berzki499

    Joined:
    Jan 10, 2016
    Posts:
    14
    Looks like that we are all waiting for Unity developers to fix this bug.
    For now, the only solution is to use some external video playback libraries.
     
  19. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    We have the same problem here, unusable.
    What we try to make is to have 1s clips that we use contextually, to react to player action. It's a face in a screen, clips are 130x130 pixels, lasting 1s, but on Android it justs freezes the app and display like the 2 last frames. Totally useless.
    Please unity make something about this
     
  20. ogs091

    ogs091

    Joined:
    Jun 2, 2017
    Posts:
    1
    I have the same problem. When I try to play the video, everything hangs for about 4 seconds. I tried preparing the video in a background thread but Unity won't allow it (has to be done in the main thread). Been stuck on this for days and I am out of ideas.
     
  21. ViicEsquivel

    ViicEsquivel

    Joined:
    Sep 23, 2014
    Posts:
    7
    Any updates in this matter? I am also having the issue...
     
  22. niufen

    niufen

    Joined:
    Aug 2, 2017
    Posts:
    2
    Any updates in this matter? I am also having the issue...!!!!!!!
     
  23. niufen

    niufen

    Joined:
    Aug 2, 2017
    Posts:
    2
  24. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Would be nice if we had some feedback from the Devs... Leaving us in the dark here! On Android this feature is unusable - everything freezes until video is prepared. Otherwise works really well. Shame this problem makes it unusable. :(
     
  25. BrianND

    BrianND

    Joined:
    May 14, 2015
    Posts:
    79
    Was there any resolution to this? This seems like a pretty serious bug.
     
  26. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
  27. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Seems to be typical of unity to just stop responding to things that they put in their "too hard basket". Clearly the devs are aware, I'm sure there's some legitimate technically issue preventing them from fixing this on Android and Windows Editor. I just wish they'd come forward and tell us rather than having us speculate..

    We added video previews for abilities in our game. It is a key component in our tech tree UI. Works excellent on iOS..but on Android it is completely unusable. We don't know if the fix is a month out or a year out - so do we ditch it or keep it in for now because there is a good chance it'll be fixed before our release date? No way to make this decision..
     
  28. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    Exactly. I could live with them saying "hey, the video player just won't stop hitching on Android for ... maybe forever". Then at least I know we should switch over now to a different method and not look back. However, if they actually are working on a fix and its going to be released in the foreseeable future, it would be a waste of money and time to scrap our current system, implement a new one, and then find out the old one was fixed.

    The lack of information here is not cool. I wish they had a better system for keeping status on certain issues that is controlled by Unity, and not 30 different threads and bug reports to look through made by users.
     
  29. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    I don't think it's a "too hard" bug to resolve. I'm sure there are plugins on the asset store that can display videos without freezing the game for 2 seconds. Maybe that's an argument for them: "if we can't make it work, just buy a plugin that do it better"
     
  30. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    My counter argument would be: I'm not using someone's 3rd party plug-in to shore up an issue in contracted software unless I'm positive it will remain an effective solution for the entire life-cycle of the project.

    I don't think that's what they're doing anyway. They rebuilt the entire VideoPlayer for a reason, and they kept touting "for VR" over and over. Well, guess what ... we're using it for VR, and its unuseable because it grinds the VR experience to a halt over and over. I'm guessing that's an issue for them ... I sure hope it is at least.
     
  31. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    For the record, we've officially let go of the VideoPlayer. We're just using Timeline to flip through the images and the audio instead for now. For this stage in the project its acceptable ... but its still pretty absurd in my opinion. If anyone else has the same issue with an ongoing project, you may want to consider this.
     
  32. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    I'm certain this stuttering bug must have been caused by an unforseen issue... As it currently stands the new Video Player is unusable on every platform. On Mobile it works on iOS but not on Android, and on desktop it works on OSX but not Windows. Only works for half the users in either case (desktop/mobile) so it's not worth using it for anything more than an intro video or full screen videos that interrupt the entire game, which the old API could handle just fine. :(
     
  33. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Bump? Any chance for a response from Unity devs?
     
  34. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    Tag them, they are more likely to read the thread
     
  35. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    Nope. No response yet.

    Bump.
     
  36. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    @r-pedra I wouldn't even know who to tag. I'm surprised the developer(s?) assigned to the new Video Play API don't check this forum category atleast a couple of times a week. Kind of goes to show how 'in tune' they are with the community. :/ The threads are even tagged 'Video', it isn't much to ask that the devs in charge take a few minutes a few times a week to just check this category. Not the whole forum. Just this category. Heck, just filter this category by the 'video' tag. There aren't that many threads.
     
    Last edited: Oct 6, 2017
  37. t-schulz

    t-schulz

    Joined:
    Feb 25, 2015
    Posts:
    13
    Our app (android) is completely blocked by the videoplayer.prepare()... why is there no help from the developers?
     
    Prodigga likes this.
  38. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    We completely removed any trace of the VideoPlayer from our Android app for this reason. Its absolutely ridiculous that Unity has not given any form of response to this issue. There are three threads that were opened on this. One of them directly tagged a Unity developer who had responded previously in the same thread, saying they were addressing the Android issue (half a year ago). And then neither he, nor anyone else, ever responded again.

    To be honest, this shows a tremendous lack of respect to any customer who ran into this issue. Not only did we spend time and money using a feature that was supposedly finished only to have to rip it out and implement a new system, but they have not even bothered to respond.

    I'm pretty amazed, to be honest. Usually they're pretty good about eventually responding to something that requires it, but this has been completely ignored after it was already stated they're aware of the issue, know what it is, and actively fixing it.
     
    Last edited: Oct 11, 2017
  39. t-schulz

    t-schulz

    Joined:
    Feb 25, 2015
    Posts:
    13
    Do anyone got an alternative videplayer for unity that works with url streaming on android and ios? Thank you
     
  40. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hi, I'm adding my anger to this problem. This is a MAJOR issue to the Video Player, maybe it's time to communicate something, at least "This is the problem, we are trying to sort it out, here's maybe some workaround".

    I don't know if Unity dev are being conscient that this is a total no-go for the video player solution on mobile platform ? Worst of everyting : I went from Unity 2017.1.1p4 ti Unity 2017.2, it's worst than before. Prepare() is now block the app forever 1 out of 3 times. Nice.

    My post is pretty much pointless because I don't bring answer but maybe if we are enough, some communication will come...
     
  41. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    5 months of silence on a feature killer issue is just absolutely atrocious
     
  42. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    I'll throw my two cents of anger as well. I just spoke to Unity trying to get direct support to handle issues like this (do we use it? Should we yank it? Is it being fixed?), and they offer support ... for 15k a year minimum. Its probably great for larger teams, but smaller teams have nothing they can do.
     
  43. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Unbelievable that no one from Unity has any follow up yet lol
     
  44. im-berzki

    im-berzki

    Joined:
    Oct 14, 2017
    Posts:
    2
    This bug is marked as fixed
    https://issuetracker.unity3d.com/is...s-a-delay-after-using-videoplayer-dot-prepare

    But I'm still getting a delay and game freeze on Android.

    Unity? Can you comment on this? Why are you still ignoring users request?

     
  45. lulitd

    lulitd

    Joined:
    Feb 20, 2016
    Posts:
    13
    Did you guys manage to find a solution? or an alternative player that supports streaming?
    Though the bug is marked fixed for 2017.2 it appears to still be a bug for Android, as I am currently using 2017.2.0f3.

    Currently making a quiz app where a video is shown before answering each question.

    I've added a loading spinner to rotate while the video is being prepared. I can see the spinner freeze. Its rotation is being updated through Update(as a test) which indicates that the whole game is freezing.
     
  46. dyuldashev

    dyuldashev

    Joined:
    Mar 3, 2016
    Posts:
    76
    Hello. Have this been fixed? I am using Unity 2017.2 for Android, and it just keeps preparing a short video forever from the Streaming Assets folder. Would you guys please resolve this issue? Thanks.
     
    deltamish and IQpierce like this.
  47. deltamish

    deltamish

    Joined:
    Nov 1, 2012
    Posts:
    58
    I know this is out of the thread topic. But since Unity 2018 videplayer no longer seems to play videos. Its just loads the first frame and sits there. No update what so ever.

    If you guys know any workaround kindly do let me know.

    Thanks
     
  48. Ederic

    Ederic

    Joined:
    Jan 21, 2014
    Posts:
    2
    Hello. Have this been fixed? I am using Unity 2017.2 for Android, and it just keeps preparing a short video forever from the Streaming Assets folder. Would you guys please resolve this issue? Thanks.
     
  49. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Feels like it is abandoned like UNET
     
  50. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    285
    VideoPlayer is a Unity feature. I suppose that abandon it it's not an option for the company.
    In my case I'm developing a video based game and I need the video player to work as intended. On IOS/Windows it works fine, on Android it doesn't, on Mac OSX it's a joke.
    Unity as a company should inform us about what it's happening with this kind of video problems and when will be fixed.
    In my case, I will not be able to publish my game if this silence continues.
     
    Last edited: Mar 16, 2018