public bool GetAudioMute(ushort trackIndex) { if (useAudioPlayer) { if (audioPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { return(audioPlayer.GetDirectAudioMute(trackIndex)); } else if (audioPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { return(audioPlayer.GetTargetAudioSource(trackIndex).mute); } } else { if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { return(videoPlayer.GetDirectAudioMute(trackIndex)); } else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { return(videoPlayer.GetTargetAudioSource(trackIndex).mute); } } return(false); }
// Gets the audio mute status for the specified track. public bool IsAudioMute(ushort track) { if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { return(videoPlayer.GetDirectAudioMute(track)); } else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { return(videoPlayer.GetTargetAudioSource(track).mute); } return(false); }
public void video_Click() { if (video41.isPlaying) { video41.Pause(); video41.GetTargetAudioSource(0).Pause(); } else { video41.Play(); video41.GetTargetAudioSource(0).UnPause(); } }
private void PauseAudio(bool pause) { for (ushort trackNumber = 0; trackNumber < videoPlayer.audioTrackCount; ++trackNumber) { if (pause) { videoPlayer.GetTargetAudioSource(trackNumber).Pause(); } else { videoPlayer.GetTargetAudioSource(trackNumber).UnPause(); } } }
public void PrepareVideo() { if (videoPlayer == null || videoClip == null) { return; } videoPlayer.targetCameraAlpha = 0.0f; if (videoPlayer.clip != videoClip) { StopVideo(); } if (videoPlayer.isPrepared || preparing) { return; } //Debug.Log($"[{nameof(PrepareVideo)}] videoPlayer null? {videoClip == null}"); videoPlayer.source = VideoSource.VideoClip; videoPlayer.clip = videoClip; videoPlayer.playOnAwake = false; videoPlayer.waitForFirstFrame = true; videoPlayer.isLooping = loop; for (ushort i = 0; i < videoClip.audioTrackCount; ++i) { if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { videoPlayer.SetDirectAudioMute(i, mute || !Application.isPlaying); } else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { AudioSource audioSource = videoPlayer.GetTargetAudioSource(i); if (audioSource != null) { audioSource.mute = mute || !Application.isPlaying; } } } videoPlayer.loopPointReached += LoopPointReached; videoPlayer.time = TimelineClip.clipIn; //Debug.LogError("PrepareCalled"); videoPlayer.Prepare(); preparing = true; }
///Sample an VideoClip in the specified VideoPlayer directly public static void Sample(VideoPlayer source, VideoClip clip, float time, float previousTime, SampleSettings settings) { if (source == null) { return; } if (previousTime == time) { source.time = time; source.Pause(); return; } source.clip = clip; source.renderMode = (VideoRenderMode)settings.renderTarget; source.playbackSpeed = settings.playbackSpeed; source.targetCameraAlpha = settings.alpha; source.aspectRatio = settings.aspectRatio; source.GetTargetAudioSource(0).volume = settings.audioVolume; time = Mathf.Repeat(time, (float)clip.length - 0.001f); if (!source.isPlaying) { source.Play(); source.time = time; } if (Mathf.Abs((float)source.time - time) > 0.1f * Time.timeScale) { source.time = time; } }
internal override void ReceivedMovieTexture(VideoPlayer tex) { // Apply it now: AssignClip(tex.GetTargetAudioSource(0).clip); base.ReceivedMovieTexture(tex); }
public void PrepareVideo() { if (videoPlayer == null || renderTexture == null || videoClip == null || image == null) { return; } videoPlayer.targetCameraAlpha = 0.0f; if (videoPlayer.clip != videoClip) { StopVideo(); } if (videoPlayer.isPrepared || preparing) { return; } videoPlayer.source = VideoSource.VideoClip; videoPlayer.clip = videoClip; videoPlayer.playOnAwake = false; videoPlayer.waitForFirstFrame = true; videoPlayer.isLooping = loop; for (ushort i = 0; i < videoClip.audioTrackCount; ++i) { if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { videoPlayer.SetDirectAudioMute(i, mute || !Application.isPlaying); } else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { AudioSource audioSource = videoPlayer.GetTargetAudioSource(i); if (audioSource != null) { audioSource.mute = mute || !Application.isPlaying; } } } videoPlayer.time = startTime; videoPlayer.Prepare(); preparing = true; }
public void SetVolume() { if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { AudioSource src = videoPlayer.GetTargetAudioSource(0); src.volume = _slider.value; } else { videoPlayer.SetDirectAudioVolume(0, _slider.value); } }
public void OnVolumeUp() { float volume = videoPlayer.GetTargetAudioSource(0).volume; if (volume < 1.0f) { volume += 0.2f; videoPlayer.GetTargetAudioSource(0).volume = volume; } else { videoPlayer.GetTargetAudioSource(0).volume = 1.0f; } }
// Update is called once per frame void Update() { if (_strTemp != null) { Debug.Log(_strTemp); switch (_strTemp) { case "P": if (_isVideoPlay) { if (VideoPlayer.isPlaying) { VideoPlayer.Pause(); } else { VideoPlayer.Play(); } } break; case "Z": if (_isVideoPlay) { //VideoPlayer.url = _videoList[_curVideoIndex]; VideoPlayer.frame = 0; VideoPlayer.Play(); } break; case "S": SetWindows(false); VideoPlayer.Stop(); AudioSource.Stop(); break; case "Up": VideoPlayer.GetTargetAudioSource(0).volume += 0.1f; break; case "Down": VideoPlayer.GetTargetAudioSource(0).volume -= 0.1f; break; case "BgSound": AudioSource.mute = !AudioSource.mute; break; case "BgSoundVol": AudioSource.mute = false; break; case "SongVolUp": AudioSource.volume += 0.1f; break; case "loopTrue": _isLoop = true; break; case "loopFalse": _isLoop = false; break; case "SongVolDown": AudioSource.volume -= 0.1f; break; default: if (_strTemp.Contains("video")) //视频 { try { int index = int.Parse(_strTemp.Substring(5, _strTemp.Length - 1 - 4)) - 1; _curVideoIndex = index; PlayVideo(); VideoPlayer.isLooping = _isLoop; } catch (Exception e) { } } else if (_strTemp.Contains("song")) //音频 { try { int index = int.Parse(_strTemp.Substring(4, _strTemp.Length - 1 - 3)) - 1; Debug.Log("audio index " + index); _curAudioIndex = index; PlayAudio(); } catch (Exception e) { } } break; } _strTemp = null; } #region 视频事件 if (VideoPlayer.isPlaying) { if (!VideoPlayer.isLooping) { //Debug.Log(VideoPlayer.frame +" <==> " + VideoPlayer.frameCount); if (VideoPlayer.frame <= 0) { return; } if ((ulong)VideoPlayer.frame >= VideoPlayer.frameCount - 10) { if (_isVideoPlay) { // _strTemp = "S"; } } } } #endregion }
private void Awake() { audioSource = videoPlayer.GetTargetAudioSource(0); audioSource.volume = 0.0001f; }
// Mute or unmute the tutorial public override void MuteTutorial(bool muted) { tutorialVideo.GetTargetAudioSource(0).mute = muted; }
// Mute or unmute the tutorial public override void MuteTutorial(bool muted) { videoPlayer.GetTargetAudioSource(0).mute = muted; }
public void Volume(float num) { VideoPlayerBind.GetTargetAudioSource(0).volume = num; }