ok iveビデオプレイヤーを以前に使用したことがありません。アンドロイドとエディタで動画を再生できますが、オーディオは再生されません。URLからビデオを取得し、ビデオプレーヤーを同じオーディオソースビデオプレーヤーコンポーネントが装着されているように、オブジェクト、IVEはこのリンクUsing new Unity VideoPlayer and VideoClip API to play videoからの助言に従ったがhaventははまだ以下のいずれかの喜びを持っていたイム言及した映像作品が、オーディオdoesntのようにそれを呼び出す方法の順で、誰もがユニティビデオプレーヤーでオーディオが再生されないのはなぜですか?
private AudioSource audio;
private VideoPlayer screen;
screen = go.GetComponentInChildren<VideoPlayer>();
audio = go.GetComponentInChildren<AudioSource>();
audio.playOnAwake = false;
screen.source = VideoSource.Url;
screen.url = videoObj.VideoURL;
screen.audioOutputMode = VideoAudioOutputMode.AudioSource;
screen.EnableAudioTrack (0,true);
screen.SetTargetAudioSource (0,audio);
screen.Prepare();
screen.Play();
audio.Play();
を助けることができます編集
以下のコメントに私はいくつかの情報を追加していますいくつかの点があるので、統一バージョンは2017です。オーディオはエディタやデバイスで再生されませんが、ビデオはエディタやデバイスで正常に動作します。ここではURLはhttps://storage.googleapis.com/godapp-a3e4b.appspot.com/jacopatrolmontage.mp4です。ここでは完全なコードです。私が使用している方法は、私は団結にかなり新しいですし、C#
public void showPlayer(VideoObjects videoObj)
{
if (GameObject.Find("videoPlaner(Clone)") == null)
{
//may need scene.isValid
GameObject go = Instantiate(videoPlayer);
go.transform.SetParent(canvas.transform, false);
screen = go.GetComponentInChildren<VideoPlayer>();
audio = go.GetComponentInChildren<AudioSource>();
//audio = go.AddComponent<AudioSource>();
fsscreenBool = true;
screenSize = go.GetComponent<Transform>().localScale;
screenPosition = go.GetComponent<Transform>().localPosition;
canvasRectTransformScale = go.GetComponentInParent<RectTransform>
();
foreach (Transform tr in go.transform)
{
if (tr.gameObject.tag == "play")
{
Button play = tr.GetComponent<Button>();
AddPlayListener(play, screen);
preparePlayer(play,screen.isPlaying);
}
if (tr.gameObject.tag == "fullscreen")
{
Button fullScreen = tr.GetComponent<Button>();
AddFSListener(fullScreen, go);
}
if (tr.gameObject.tag == "forward")
{
}
if (tr.gameObject.tag == "rewind")
{
}
if (tr.gameObject.tag == "vidtitle")
{
tr.GetComponent<Text>().text = videoObj.VideoTitle;
}
if (tr.gameObject.tag == "loading")
{
loading = tr.gameObject;
}
}
}
else{
//print("it exists");
GameObject existingGO = GameObject.Find("videoPlaner(Clone)");
screen = existingGO.GetComponentInChildren<VideoPlayer>();
loading.SetActive (true);
foreach (Transform tr in existingGO.transform)
{
if (tr.gameObject.tag == "play")
{
}
if (tr.gameObject.tag == "fullscreen")
{
checkScreen (existingGO);
}
if (tr.gameObject.tag == "forward")
{
}
if (tr.gameObject.tag == "rewind")
{
}
if (tr.gameObject.tag == "vidtitle")
{
tr.GetComponent<Text>().text = videoObj.VideoTitle;
}
if (tr.gameObject.tag == "loading")
{
}
}
}
screen.source = VideoSource.Url;
screen.url = videoObj.VideoURL;
screen.audioOutputMode = VideoAudioOutputMode.AudioSource;
screen.EnableAudioTrack (0,true);
screen.SetTargetAudioSource (0,audio);
screen.Prepare();
audio.Play();
screen.Play();
}
は、あなたがしようとしている動画のURL、完全なコードを投稿しても、Unityのバージョンに言及することはできます。オーディオはエディタで機能しますか? – Programmer
@Programmerが質問を編集して回答に感謝の意を表します – martinseal1987
これを調べる前に、[質問](https://stackoverflow.com/questions/41144054/using-新しいユニティビデオプレイヤーとビデオクリップの両方にリンクしています)それをコピー&ペーストするだけで、 'VideoSource.Url;'部分を変更してURLを追加します。それを再生して、あなたがオーディオを持っているかどうかを確認してください – Programmer