Search Unity

Video Imcompatibility issues

Discussion in 'Audio & Video' started by sargeirolucas, May 26, 2019.

  1. sargeirolucas

    sargeirolucas

    Joined:
    May 26, 2019
    Posts:
    1
    I'm having problems to run project. I did it at a 2018.1.9f2 version (for windows) and works perfectly, but now I'm trying to use in a 2018.3.0f2 version (for linux) and I'm having the errors:

    starts with
    "
    Packages were changed.
    Update Mode: updateDependencies

    The following packages were added:
    com.unity.analytics@3.2.2
    com.unity.purchasing@2.0.3
    com.unity.ads@2.3.1
    com.unity.textmeshpro@1.3.0
    com.unity.package-manager-ui@2.0.3
    com.unity.collab-proxy@1.2.15
    com.unity.modules.ai@1.0.0
    com.unity.modules.animation@1.0.0
    com.unity.modules.assetbundle@1.0.0
    com.unity.modules.audio@1.0.0
    com.unity.modules.cloth@1.0.0
    com.unity.modules.director@1.0.0
    com.unity.modules.imageconversion@1.0.0
    com.unity.modules.imgui@1.0.0
    com.unity.modules.jsonserialize@1.0.0
    com.unity.modules.particlesystem@1.0.0
    com.unity.modules.physics@1.0.0
    com.unity.modules.physics2d@1.0.0
    com.unity.modules.screencapture@1.0.0
    com.unity.modules.terrain@1.0.0
    com.unity.modules.terrainphysics@1.0.0
    com.unity.modules.tilemap@1.0.0
    com.unity.modules.ui@1.0.0
    com.unity.modules.uielements@1.0.0
    com.unity.modules.umbra@1.0.0
    com.unity.modules.unityanalytics@1.0.0
    com.unity.modules.unitywebrequest@1.0.0
    com.unity.modules.unitywebrequestassetbundle@1.0.0
    com.unity.modules.unitywebrequestaudio@1.0.0
    com.unity.modules.unitywebrequesttexture@1.0.0
    com.unity.modules.unitywebrequestwww@1.0.0
    com.unity.modules.vehicles@1.0.0
    com.unity.modules.video@1.0.0
    com.unity.modules.vr@1.0.0
    com.unity.modules.wind@1.0.0
    com.unity.modules.xr@1.0.0"

    and when I try to run de project
    "Can't play movie [http://icjoel.000webhostapp.com/videos/1.mp4]
    UnityEngine.Video.VideoPlayer:set_url(String)
    <playVideo>c__Iterator0:MoveNext() (at Assets/Scripts/video.cs:50)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    video:Start() (at Assets/Scripts/video.cs:22)"

    here the script I'm using:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.Video;
    6.  
    7. public class video : MonoBehaviour {
    8.  
    9.     private VideoPlayer videoPlayer;
    10.     private VideoSource videoSource;
    11.     private AudioSource audioSource;
    12.  
    13.     public string video_url = "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4";
    14.  
    15.     public VideoClip videoToPlay;
    16.  
    17.     public RawImage image;
    18.  
    19.     // Use this for initialization
    20.     void Start () {
    21.         Application.runInBackground = true;
    22.         StartCoroutine(playVideo());
    23.        
    24.     }
    25.    
    26.     // Update is called once per frame
    27.     void Update () {
    28.        
    29.     }
    30.  
    31.     IEnumerator playVideo(){
    32.  
    33.         //Add VideoPlayer to the GameObject
    34.         videoPlayer = gameObject.AddComponent<VideoPlayer>();
    35.  
    36.         //Add AudioSource
    37.         audioSource = gameObject.AddComponent<AudioSource>();
    38.  
    39.         //Disable Play on Awake for both Video and Audio
    40.         videoPlayer.playOnAwake = false;
    41.         audioSource.playOnAwake = false;
    42.         audioSource.Pause();
    43.  
    44.         //We want to play from video clip not from url
    45.        
    46.         //videoPlayer.source = VideoSource.VideoClip;
    47.  
    48.         // Vide clip from Url
    49.         videoPlayer.source = VideoSource.Url;
    50.         videoPlayer.url = video_url;
    51.  
    52.  
    53.         //Set Audio Output to AudioSource
    54.         videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
    55.  
    56.         //Assign the Audio from Video to AudioSource to be played
    57.         videoPlayer.EnableAudioTrack(0, true);
    58.         videoPlayer.SetTargetAudioSource(0, audioSource);
    59.  
    60.         //Set video To Play then prepare Audio to prevent Buffering
    61.         videoPlayer.clip = videoToPlay;
    62.         videoPlayer.Prepare();
    63.  
    64.         //Wait until video is prepared
    65.         WaitForSeconds waitTime = new WaitForSeconds(1);
    66.         while (!videoPlayer.isPrepared)
    67.         {
    68.             Debug.Log("Preparing Video");
    69.             //Prepare/Wait for 5 sceonds only
    70.             yield return waitTime;
    71.             //Break out of the while loop after 5 seconds wait
    72.             break;
    73.         }
    74.  
    75.         Debug.Log("Done Preparing Video");
    76.  
    77.         //Assign the Texture from Video to RawImage to be displayed
    78.         //image.texture = videoPlayer.texture;
    79.  
    80.         //Play Video
    81.         videoPlayer.Play();
    82.  
    83.         //Play Sound
    84.         audioSource.Play();
    85.  
    86.         Debug.Log("Playing Video");
    87.         while (videoPlayer.isPlaying)
    88.         {
    89.             Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)videoPlayer.time));
    90.             yield return null;
    91.         }
    92.         Debug.Log("Done Playing Video");
    93.    
    94.     }
    95. }
    96.