Example #1
0
 void OnVideoPrepaded(VideoPlayer vp)
 {
     vid.Play();
     vid.time = 0.2;
     vid.Pause();
     anim.SetTrigger("In");
     StartCoroutine(PlaySequence());
     Debug.Log(vid.GetAudioChannelCount(0));
     music.SetBool("on", vid.GetAudioChannelCount(0).ToString() == "0");
 }
Example #2
0
        GUIContent GetAudioTrackEnabledContent(ushort trackIdx)
        {
            while (m_AudioTrackInfos.Count <= trackIdx)
            {
                m_AudioTrackInfos.Add(new AudioTrackInfo());
            }

            AudioTrackInfo info = m_AudioTrackInfos[trackIdx];

            VideoPlayer player = null;

            if (!serializedObject.isEditingMultipleObjects)
            {
                player = (VideoPlayer)target;
            }

            // Only produce a decorated track label with single-selection.  No
            // point trying to come up with a label that makes the average of
            // the current track params...
            string language     = player ? player.GetAudioLanguageCode(trackIdx) : "";
            ushort channelCount = player ? player.GetAudioChannelCount(trackIdx) : (ushort)0;

            if (language != info.language || channelCount != info.channelCount || info.content == null)
            {
                string trackDetails = "";
                if (language.Length > 0)
                {
                    trackDetails += language;
                }

                if (channelCount > 0)
                {
                    if (trackDetails.Length > 0)
                    {
                        trackDetails += ", ";
                    }
                    trackDetails += channelCount.ToString() + " ch";
                }

                if (trackDetails.Length > 0)
                {
                    trackDetails = " [" + trackDetails + "]";
                }

                info.content         = EditorGUIUtility.TextContent("Track " + trackIdx + trackDetails);
                info.content.tooltip = s_Styles.enableDecodingTooltip;
            }

            return(info.content);
        }
Example #3
0
    void PrepareCompleted(VideoPlayer vp)
    {
        Debug.Log("(SJM) " + Time.time + " Video Prepare Completed.");
        Debug.Log("(SJM) " + " ");
        Debug.Log("(SJM) " + "video URL: " + vp.url);
        Debug.Log("(SJM) " + "audio output mode: " + vp.audioOutputMode.ToString());
        Debug.Log("(SJM) " + "isPrepared: " + vp.isPrepared.ToString());
        Debug.Log("(SJM) " + "frame: " + vp.frame.ToString());
        Debug.Log("(SJM) " + "video frame count: " + vp.frameCount.ToString());
        Debug.Log("(SJM) " + "audio track count: " + vp.audioTrackCount.ToString());
        Debug.Log("(SJM) " + "length (seconds): " + vp.length.ToString());
        Debug.Log("(SJM) " + "playOnAwake: " + vp.playOnAwake.ToString());
        Debug.Log("(SJM) " + "waitForFirstFrame: " + vp.waitForFirstFrame.ToString());
        Debug.Log("(SJM) " + "frameRate: " + vp.frameRate.ToString());
        Debug.Log("(SJM) " + "GetAudioChannelCount: " + vp.GetAudioChannelCount(0).ToString());
        Debug.Log("(SJM) " + "IsAudioTrackEnabled: " + vp.IsAudioTrackEnabled(0).ToString());
        Debug.Log("(SJM) " + " ");

        vp.Play();
    }
Example #4
0
        private GUIContent GetAudioTrackEnabledContent(ushort trackIdx)
        {
            while (this.m_AudioTrackInfos.Count <= (int)trackIdx)
            {
                this.m_AudioTrackInfos.Add(new VideoPlayerEditor.AudioTrackInfo());
            }
            VideoPlayerEditor.AudioTrackInfo audioTrackInfo = this.m_AudioTrackInfos[(int)trackIdx];
            VideoPlayer videoPlayer = null;

            if (!base.serializedObject.isEditingMultipleObjects)
            {
                videoPlayer = (VideoPlayer)base.target;
            }
            string text = (!videoPlayer) ? "" : videoPlayer.GetAudioLanguageCode(trackIdx);
            ushort num  = (!videoPlayer) ? 0 : videoPlayer.GetAudioChannelCount(trackIdx);

            if (text != audioTrackInfo.language || num != audioTrackInfo.channelCount || audioTrackInfo.content == null)
            {
                string text2 = "";
                if (text.Length > 0)
                {
                    text2 += text;
                }
                if (num > 0)
                {
                    if (text2.Length > 0)
                    {
                        text2 += ", ";
                    }
                    text2 = text2 + num.ToString() + " ch";
                }
                if (text2.Length > 0)
                {
                    text2 = " [" + text2 + "]";
                }
                audioTrackInfo.content         = EditorGUIUtility.TextContent("Track " + trackIdx + text2);
                audioTrackInfo.content.tooltip = VideoPlayerEditor.s_Styles.enableDecodingTooltip;
            }
            return(audioTrackInfo.content);
        }
        public void PlayVideo(bool preview)
        {
            if (hasVideo || (!showVideo && !preview)) //If the current video is null or not downloaded or show video is off AND it isn't a preview hide the screen
            {
                HideScreen();
                return;
            }

            ShowScreen();
            vsRenderer.material.color = _onColor;
            float practiceSettingsSongStart = 0;

            if (!preview)
            {
                try     // Try to get these, as errors happen when only previewing (and they are unnecessary)
                {
                    try // Try to get these as there will be a null reference if not in practice mode or only previewing
                    {
                        practiceSettingsSongStart =
                            BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.startSongTime - 1;
                        if (practiceSettingsSongStart < 0)
                        {
                            practiceSettingsSongStart = 0;
                        }
                    }
                    catch (NullReferenceException)
                    {
                        practiceSettingsSongStart = 0;
                    }

                    float songSpeed = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul;
                    videoPlayer.playbackSpeed =
                        BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings != null
                            ? BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul
                            : songSpeed; // Set video speed to practice or non-practice speed

                    if (offsetSec + practiceSettingsSongStart > 0)
                    {
                        videoPlayer.time = offsetSec + practiceSettingsSongStart;
                    }
                    else
                    {
                        videoPlayer.time = 0;
                    }
                }
                catch (Exception e)
                {
                    Plugin.logger.Debug("Probably cause previews don't have speed mults");
                    Plugin.logger.Error(e.ToString());
                }

                for (ushort track = 0;
                     track < videoPlayer.audioTrackCount;
                     track++) // For Each Track -> Decrease Audio volume to 0 on that track
                {
                    // videoPlayer.SetDirectAudioMute(track, true);
                    videoPlayer.SetDirectAudioVolume(track, 0f);
                }

                if (rotateIn360)
                {
                    try
                    {
                        Plugin.logger.Debug(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.environmentInfo.environmentType.name);
                        CoreGameHUDController cgh = Resources.FindObjectsOfTypeAll <CoreGameHUDController>()
                                                    .LastOrDefault(x => x.isActiveAndEnabled);
                        screenSoftParentRotation.AssignParent(cgh.transform);
                    }
                    catch { }
                    //Null reference if done in preview
                    screenSoftParentRotation.enabled = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.environmentInfo.environmentType.name == "CircleEvironmentType";
                }
            }
            else
            {
                videoPlayer.time          = offsetSec > 0 ? offsetSec : 0;
                videoPlayer.playbackSpeed = 1;
                //TODO: Make Left Ear Audio the Preview and Right Ear Audio the BeatMap
                //ushort videoTrack = 1;
                for (ushort track = 0;
                     track < videoPlayer.audioTrackCount;
                     track++) // For Each Track -> Increase Audio volume to .5 (float) on that track
                {
                    //if (track != videoTrack) { videoPlayer.SetDirectAudioVolume(track, 0f); continue;}
                    bool failed = false;
                    try
                    {
                        videoPlayer.SetDirectAudioVolume(track, playPreviewAudio ? .8f : 0f);
                        Plugin.logger.Debug($"Channels: {videoPlayer.GetAudioChannelCount(track)}");
                    }
                    catch (Exception)
                    {
                        failed = true;
                    }
                    Plugin.logger.Debug($"Track: {track} {(failed ? "Failed" : "Succeeded")}");
                }
                Plugin.logger.Debug("Done lower volume");
            }
            Plugin.logger.Debug("Offset for video: " + offsetSec);
            StopAllCoroutines();
            StartCoroutine(StartVideoDelayed(preview ? -offsetSec : -(offsetSec + practiceSettingsSongStart), preview));
        }