Seeking Performance Delay On Android

Preface: I have gotten some basic controls working for the new VideoPlayer component, and I have everything working well in the editor. However, when I run the scene on my Android device, I run into some problems.

Main problem: When I play the video (for example for 100 frames), and then set the video player back to frame 50, the video will freeze up for a few seconds. This freeze time increases the farther along you are in the video. (Going from 100 to 50 frames takes 1 sec, going from 5000 to 4000 frames takes 10+ seconds.)

Seeking to a specific frame does eventually work, but takes a long time on Android.

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;

public class VideoPlayerControl : MonoBehaviour {

    [Header("Settings")]
    [Range(0.1f, 10f)]
    public float playbackSpeed = 1f;

    [Header("UI Controls")]
    public Slider progressBar;

    //Private vars
    VideoPlayer vPlayer;
    public int vidFrameLength;
    bool shouldStartPlaying = true;

    // Use this for initialization
    void Start () {
        vPlayer = gameObject.GetComponent<VideoPlayer>();

        vPlayer.playbackSpeed = playbackSpeed;
        vPlayer.Prepare();
        vidFrameLength = (int)vPlayer.frameCount;

        progressBar.maxValue = vidFrameLength;
    }

    // Update is called once per frame
    void Update () {
        if(shouldStartPlaying && vPlayer.isPrepared){
            Play();
            shouldStartPlaying = false;
        }
    }

    public void Play(){
        vPlayer.Play();
    }

    public void Pause(){
        vPlayer.Pause();
    }

    public void Stop(){
        vPlayer.Stop();
    }

//This is called by the slider (Event Trigger: End Drag)
    public void SetFrameBySlider(){
        JumpToFrame(progressBar.value);
    }

    public void JumpToFrame(float frame){
        vPlayer.frame = (long)frame;
    }
}

Conclusion: If anyone else has tried getting seeking working on Android, and has a better solution or any tips, I'd appreciate it. I've seen that some people say that the VideoPlayer is not fully working on Android, but I'm not sure what Unity's support level is for this feature.

Notes: I'm testing on a Google Pixel (Android 7.1). I am testing with a video that uses all Unity's recommended specs.

We had some success with Seek by going to the latest Unity 2017. Ours was totally freezing and now it works well.

1 Like


Are you testing on Android? Also, what beta are you on? I tested again in 2017.1.0b6 and it's still present.

@Bandit-Development

We have been seeing changes on every beta release. Just today we had to update to 0b7 because one device was super choppy on search. Now we have a search that seems to work on most of our devices. Id do that first.

Are you sure your codec is the right one for android? It's been sensitive to that too. How long is the video?

1 Like

I updated to Unity 2017.1.0b7, made sure my video was using Unity's advised specs, and I'm still experiencing delayed seeking and frame control.

Currently, my video is 1:40 long, 1280x666, H264 codec. What settings do you have for your video?


Sorry @Bandit-Development , missed your post. Did you fix it?

@AquaGhost Not really, tried on beta 10 and it's still present. However, I'm running into bugs on iOS and Mac too, so think I'm going to use a custom video asset solution.

Thanks for your help and info.

I'm also having the same problem. Though the problem only exist in Android and works perfectly in iOS.

iOS -> .mov/.mp4 works fine
Android -> .mov/.mp4 not fine...

sorry guys, have you found the solution?