Search Unity

Video How do do i change video clip source using C#?

Discussion in 'Audio & Video' started by saeed786129, Jan 30, 2020.

  1. saeed786129

    saeed786129

    Joined:
    Sep 14, 2019
    Posts:
    4
    Hi,

    I'm trying to change the source of the video clip through C#. I don't want to use URL's i have imported the videos into my project.

    Example of what I want to do:

    VideoClip videoClip = 'Assets/Video.mp4';

    I know the code above wont work.
    Does anyone have a solution?
    Would be much appreciated.
     
  2. mcmount

    mcmount

    Joined:
    Nov 15, 2015
    Posts:
    83
    yep. This is the basics you get the idea of the power of the Unity, not just for gaming...
    The Streaming Assets folder is your folder for any external content. Internal, just C#:

    public VideoPlayer vid;
    public VideoClip myclip;

    Drag your player, and drag your clip in inspector and just bang in fancy stuff like this:
    vid.playbackSpeed = .1f + (Mathf.PerlinNoise(Time.time * .1f, 0f)*4f); (variates the speed)
    or just say;
    vid.clip = myclip;
     
    vandale_ likes this.
  3. jaimelugo

    jaimelugo

    Joined:
    Nov 8, 2019
    Posts:
    27
    thanks a lot McMount!!
     
  4. vandale_

    vandale_

    Joined:
    Aug 16, 2019
    Posts:
    3
    thank you mcmount, this helped :)