unityに新しく導入された動画再生コンポーネントVideoplayerを使ってみましたが、音がデフォルトでは再生されないみたいだったのでスクリプトをかきました。
このサイトを参考にしました。
が、このコードで問題なく動くのですが気になったことがあります。
1つ目
まず一つが音質です。音が途中でプつプつなるのですがこれは仕様でしょうか?
2つ目
C#
1 videoPlayer.EnableAudioTrack (0, true); 2 videoPlayer.SetTargetAudioSource (0, audioSource); 3 videoPlayer.clip = videoToPlay;
上記のコードですがここが何をしているのかさっぱりわかりません。
このサイト
ではそれらしいことは書いてありましたが根本的なことはわかっていないようです。
どなたかわかる方いらっしゃらないでしょうか。
コード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5using UnityEngine.Video; 6public class NewVideoClipController : MonoBehaviour { 7 8 public RawImage image; 9 public RenderTexture r ; 10 public VideoClip videoToPlay; 11 private VideoPlayer videoPlayer; 12 private VideoSource videoSource; 13 private AudioSource audioSource; 14 15 void Start () { 16 videoPlayer = gameObject.AddComponent<VideoPlayer>(); 17 audioSource = gameObject.AddComponent<AudioSource>(); 18 image.texture = r; 19 videoPlayer.targetTexture = r; 20 videoPlayer.EnableAudioTrack (0, true); 21 videoPlayer.SetTargetAudioSource (0, audioSource); 22 videoPlayer.clip = videoToPlay; 23 videoPlayer.isLooping = true; 24 videoPlayer.Play (); 25 } 26 void Update () { 27 28 } 29} 30
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/09 05:32 編集
2017/11/09 04:11
2017/11/09 05:32
2017/11/09 05:54
2017/11/09 06:12