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のどこが原因かは定かではありません.なんとなくですが,ポート番号が怪しい(ポート番号の指定は無視されデフォルトのポート番号が使われているような)気がしています.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 件のコメント:
コメントを投稿