视频播放会在最后几秒钟中断

时间:2019-01-21 20:42:51

标签: unity3d

我正在统一播放视频,短片没问题,但是长片会在最后几秒钟切断。我的视频是52秒,播放约50秒后停止播放。我从网上尝试了一个2:45随机视频,但在2:41之后停止了播放。我不知道发生了什么。

我尝试了视频剪辑和URL。两者都有问题。

IEnumerator playVideo(SubjectClipState clipState)
{
    clipState.clipObject.videoPlayer.Stop();
    clipState.clipObject.audioSource.Stop();

    clipState.clipObject.videoPlayer.playOnAwake = false;
    clipState.clipObject.audioSource.playOnAwake = false;
    clipState.clipObject.videoPlayer.source = VideoSource.Url;
    clipState.clipObject.videoPlayer.audioOutputMode = clipState.clipConfig.hasAudio ? VideoAudioOutputMode.AudioSource : VideoAudioOutputMode.None;
    clipState.clipObject.videoPlayer.controlledAudioTrackCount = clipState.clipConfig.hasAudio ? Convert.ToUInt16(1) : Convert.ToUInt16(0);
    clipState.clipObject.videoPlayer.EnableAudioTrack(0, clipState.clipConfig.hasAudio);
    if (clipState.clipConfig.hasAudio) clipState.clipObject.videoPlayer.SetTargetAudioSource(0, clipState.clipObject.audioSource);
    clipState.clipObject.videoPlayer.url = clipState.clipConfig.url;
    clipState.clipObject.videoPlayer.isLooping = clipState.clipConfig.endAction.type == "loop";
    clipState.clipObject.videoPlayer.Prepare();

    while (!clipState.clipObject.videoPlayer.isPrepared)
    {
        yield return null;
    }

    clipState.clipObject.videoPlayer.Play();
}

注意:videoPlayer和audioSource在代码的其他位置设置。已附加LoopPointReached。

我正在这样玩:

StartCoroutine("playVideo", subjectClipState);

LoopPointReached将中断几秒钟,然后再完成。视频播放器的x / x帧正确。例如2740/2740帧。

1 个答案:

答案 0 :(得分:0)

好的,事实证明这是Unity 2018.2中的错误。当我升级到2018.3时,它没有中断。