2020年4月1日水曜日

Oculus GoでVideoPlayer越しにビデオを再生できない問題を解消する方法

VideoPlayerを使ってビデオを再生するOculus Go用のプログラムを作成した際に,次のメッセージが表示されて再生できないという問題に出くわしました.

Unity : AndroidVideoMedia: Error opening extractor: -10000

数日間試行錯誤を続けたところ,ビデオのURLに原因があることをつきとめました.

今回デバッグのために作成したコードは以下のとおりです. このコードの14行目でビデオのURLを指定しているのですが,それが「https://192.168.1.5:8443/test.mp4」のときに上記のエラーが発生します.このエラーを解消する方法は,ビデオを「https://hogehoge/test.mp4」というURLでアクセスできる場所に置き,そのURLをvideoPlayer.urlの値に指定するというものです.そうすると,ビデオが再生されるようになります.

原因はURLにあるところまではわかったのですが,URLのどこが原因かは定かではありません.なんとなくですが,ポート番号が怪しい(ポート番号の指定は無視されデフォルトのポート番号が使われているような)気がしています.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class BehaviourScript : MonoBehaviour
{
public VideoPlayer videoPlayer;
void Start()
{
this.videoPlayer.errorReceived += this.ErrorReceived;
this.videoPlayer.prepareCompleted += this.PrepareCompleted;
this.videoPlayer.url = "https://192.168.1.5:8443/test.mp4";
this.videoPlayer.Prepare();
}
// Update is called once per frame
void Update()
{
}
private void ErrorReceived(VideoPlayer videoPlayer, string message)
{
Debug.Log(message);
}
void PrepareCompleted(VideoPlayer videoPlayer)
{
videoPlayer.prepareCompleted -= this.PrepareCompleted;
videoPlayer.Play();
}
}

0 件のコメント: