2017-01-23 8 views
0

私はGoogle VR SDK for Unityと一緒に、SDKに付属のコンポーネントを使って簡単な360ビデオビューアを作成しようとしています。ユーザーがメニューからナビゲートしたときにソースビデオを動的に変更するためにPanoVideoSampleを拡張しようとしています。Google VR SDK(Unity) - GvrVideoPlayerTextureスワップURL

コード経由でGvrVideoPlayerTextureのURLを変更する際に問題が発生しました。デモシーン(VideoDemo)には、Video Sphereを含むPanoVideoSampleがあり、インスペクタパネルのGVRVideoPlayerTextureスクリプトを編集して適切なビデオURLを指すことができます。

ビデオURLを動的に設定するには、個別のビデオ領域をハードコードしてから非表示にする必要があります。私はほぼ次のコードでこれを動作させました。

public void SwapVideo(int index){ 

    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().videoURL = urls [index];// my new url 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().ReInitializeVideo(); 
    videoSphere.SetActive (true); 

} 

public void ReturnToMainMenu(){ 

    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().CleanupVideo(); 
    videoSphere.SetActive (false); 

    this.gameObject.SetActive (true); 

} 

上記のコードは動作しているようですが、問題は、URLが設定されており、テクスチャーが再初期化された後videoSphere上のテクスチャが白くなります。新しいビデオが読み込まれ、新しいビデオの音声が聞こえるのがわかりますが、シーンには白いテクスチャが表示されます。 See the output here

GvrVideoPlayerTextureのキーステップがないか、シーンをレンダリングするために使用されるStereoPanoSphereMaterialを更新するための追加の呼び出しがないかと思います。このSDKはかなり新しく、それについて多くの人が書いているようには見えないので、どんな助けもありがたいです。

答えて

0

最終的にGoogle VRドキュメント(Streaming Video Support)のドキュメントに私の質問に対する答えが見つかりました。 私は最初の試みで間違っていたことをまだ完全には明らかにしていませんが、これは私のために働くコードです。

videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().videoURL = urls [index]; 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().videoType = GvrVideoPlayerTexture.VideoType.Other; 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().videoProviderId = string.Empty; 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().videoContentID = string.Empty; 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().CleanupVideo(); 
    videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().ReInitializeVideo(); 
関連する問題