void Run(GimmickValue value, DateTime current, bool useSameValue)
        {
            if (playableDirector == null)
            {
                return;
            }
            if (useSameValue)
            {
                if (value.TimeStamp < LastTriggeredAt)
                {
                    return;
                }
            }
            else
            {
                if (value.TimeStamp <= LastTriggeredAt)
                {
                    return;
                }
            }
            if (stopTimelineGimmick != null && value.TimeStamp < stopTimelineGimmick.LastTriggeredAt)
            {
                return;
            }
            LastTriggeredAt = value.TimeStamp;

            OnPlay?.Invoke();
            var time = playableDirector.initialTime + (current - value.TimeStamp).TotalSeconds;

            playableDirector.time = time;
            playableDirector.Play();
        }
Example #2
0
        private static void Player_CurrentStateChanged(MediaPlayer sender, object args)
        {
            //先通知SMTC
            switch (Player.PlaybackSession.PlaybackState)
            {
            case MediaPlaybackState.Playing:
                MediaSystemControls.PlaybackStatus = MediaPlaybackStatus.Playing;
                break;

            case MediaPlaybackState.Paused:
                MediaSystemControls.PlaybackStatus = MediaPlaybackStatus.Paused;
                break;

            default:
                break;
            }

            if (Player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
            {
                Invoke(() => OnPlay?.Invoke());
            }
            else
            {
                Invoke(() => OnPause?.Invoke());
            }
        }
Example #3
0
    public virtual void Play(bool oneShot = false)
    {
        if (source == null)
        {
            Debug.Log("AudioEvent: Tried to play " + name + " with source equal to null."); return;
        }

        // Check if AudioSource is active and check cooldown time
        if (!source.gameObject.activeSelf || Time.time < nextAvailablePlayTime)
        {
            return;
        }

        source.clip  = clips[clipIndex];
        source.pitch = pitch + Random.Range(0f, randomPitch) - (randomPitch * 0.5f);

        // Play
        if (oneShot)
        {
            source.PlayOneShot(source.clip);
        }
        else
        {
            source.Play();
        }

        lastPlayedIndex = clipIndex;
        RandomizeIndex();

        lastPlayedTime        = Time.time;
        nextAvailablePlayTime = lastPlayedTime + cooldownSeconds;

        OnPlay?.Invoke();
    }
Example #4
0
 public async void RaiseOnPlay(double duration)
 {
     if (OnPlay != null)
     {
         await OnPlay.Invoke(duration);
     }
 }
        protected override void Start()
        {
            base.Start();

            btnPlay?.onClick.RemoveAllListeners();
            btnPlay?.onClick.AddListener(() => OnPlay?.Invoke());
        }
Example #6
0
        public void Play(string File)
        {
            try
            {
                if (waveOut != null)
                {
                    if (waveOut.PlaybackState != PlaybackState.Stopped)
                    {
                        waveOut.Stop();
                        audioFile.Dispose();
                        waveOut.Dispose();
                    }
                }

                waveOut             = new WasapiOut(NAudio.CoreAudioApi.AudioClientShareMode.Shared, 100);
                audioFile           = new AudioFileReader(File);
                meterSampleProvider = new MeteringSampleProvider(audioFile);
                meterSampleProvider.SamplesPerNotification = 100;
                meterSampleProvider.StreamVolume          += MeterSampleProvider_StreamVolume;

                audioFile.Volume = _volume;
                waveOut.Init(meterSampleProvider);


                waveOut.Play();
                OnPlay?.Invoke(new PlayEventArgs {
                    File = File
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        private void RTSP_ProcessPlayRequest(RtspRequestPlay message, RtspListener listener)
        {
            OnPlay?.Invoke(Id);

            Play = true;  // ACTUALLY YOU COULD PAUSE JUST THE VIDEO (or JUST THE AUDIO)
            _logger.Info($"Connection {Id} play started");

            string range    = "npt=0-";                                                  // Playing the 'video' from 0 seconds until the end
            string rtp_info = "url=" + message.RtspUri + ";seq=" + _videoSequenceNumber; // TODO Add rtptime  +";rtptime="+session.rtp_initial_timestamp;

            // Send the reply
            Rtsp.Messages.RtspResponse play_response = message.CreateResponse(_logger);
            play_response.AddHeader("Range: " + range);
            play_response.AddHeader("RTP-Info: " + rtp_info);
            listener.SendMessage(play_response);



            //TODO: find a p[lace for this check]
            // Session ID was not found in the list of Sessions. Send a 454 error

            /*   Rtsp.Messages.RtspResponse play_failed_response = (e.Message as Rtsp.Messages.RtspRequestPlay).CreateResponse();
             * play_failed_response.ReturnCode = 454; // Session Not Found
             * listener.SendMessage(play_failed_response);*/
        }
Example #8
0
        public async void AddCard(Card card, PlayerPosition playerPosition)
        {
            if (Cards.Count < gameState.TrickCards)
            {
                Cards.Add(playerPosition, card);
                PlayerTurn = GetNextPlayerPosition(playerPosition);
                OnDisplay?.Invoke();
            }

            if (Cards.Count == gameState.TrickCards)
            {
                await Task.Delay(gameState.SimulateDelay);
            }

            OnPlay?.Invoke();

            if (Cards.Count == gameState.TrickCards || gameState.RoundWinner != PlayerPosition.NoOne)
            {
                if (gameState.RoundWinner != PlayerPosition.NoOne && Cards.Count < gameState.TrickCards)
                {
                    await Task.Delay(gameState.SimulateDelay);
                }

                Cards.Clear();
                OnDisplay?.Invoke();
            }

            if (PlayerTurn == PlayerPosition.First && gameState.RoundWinner == PlayerPosition.NoOne)
            {
                OnGamePlayerTurn?.Invoke();
            }
        }
Example #9
0
    public void PlayScheduled(float delaySeconds)
    {
        if (source == null)
        {
            return;
        }

        // Check if AudioSource is active and check cooldown time (taking delay into account)
        if (!source.gameObject.activeSelf || Time.time + delaySeconds < nextAvailablePlayTime)
        {
            return;
        }

        source.clip  = clips[clipIndex];
        source.pitch = pitch + Random.Range(0f, randomPitch) - (randomPitch * 0.5f);
        source.PlayScheduled(AudioSettings.dspTime + delaySeconds);

        lastPlayedIndex = clipIndex;
        RandomizeIndex();

        lastPlayedTime        = Time.time + delaySeconds;
        nextAvailablePlayTime = lastPlayedTime + cooldownSeconds;

        OnPlay?.Invoke();
    }
Example #10
0
        public void Play()
        {
            audioSource = GetComponent <AudioSource>();

            audioSource.playOnAwake           = playOnAwake;
            audioSource.loop                  = loop;
            audioSource.outputAudioMixerGroup = outputAudioMixerGroup;
            audioSource.clip                  = clip;
            audioSource.pitch                 = pitch;
            audioSource.volume                = 1f;

            OnPlay?.Invoke();

            if (loopType == AudioLoopType.Manuel)
            {
                StartCoroutine(PlayLoop());
            }
            else
            {
                audioSource.Play();
                if (!loop)
                {
                    StartCoroutine(WaitBeforeReturningToPool());
                }
            }
        }
Example #11
0
 public void Play()
 {
     if (player != null && player.isPrepared)
     {
         OnPlay?.Invoke();
         player.Play();
     }
 }
Example #12
0
        public void OnPlayCallback(int soundId, int durationInSeconds)
        {
            TotalTime = TimeSpan.FromSeconds(durationInSeconds);

            OnPlay?.Invoke(new HowlPlayEventArgs {
                SoundId = soundId, TotalTime = TotalTime
            });
        }
Example #13
0
        private void ButtonPlayCommand_Click(object sender, RoutedEventArgs e)
        {
            Play();

            ButtonPlayCommand.Visibility  = System.Windows.Visibility.Collapsed;
            ButtonPauseCommand.Visibility = System.Windows.Visibility.Visible;

            OnPlay?.Invoke(this, EventArgs.Empty);
        }
Example #14
0
        private void OnPlayButton_Clicked()
        {
            if (selectedSquads.Count > 0)
            {
                OnPlay?.Invoke(selectedPatterns);
            }

            PlayImportantClickSound();
        }
Example #15
0
 public void Play()
 {
     if (_player.IsPlaying())
     {
         return;
     }
     OnPlay?.Invoke();
     _player.Play();
 }
Example #16
0
 private static void Player_CurrentStateChanged(MediaPlayer sender, object args)
 {
     if (Player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
     {
         Invoke(() => OnPlay?.Invoke());
     }
     else
     {
         Invoke(() => OnPause?.Invoke());
     }
 }
Example #17
0
        public void OnPlayCallback(int soundId, double?durationInSeconds)
        {
            if (durationInSeconds is not null)
            {
                TotalTime = TimeSpan.FromSeconds(durationInSeconds.Value);
            }

            OnPlay?.Invoke(new HowlPlayEventArgs {
                SoundId = soundId, TotalTime = TotalTime
            });
        }
Example #18
0
 public void ResumePlaying()
 {
     if (OnPlay != null)
     {
         OnPlay.Invoke(Sound, this);
     }
     HideAll();
     BtnPause.gameObject.SetActive(true);
     Progress.gameObject.SetActive(true);
     Progress.value = 0;
 }
Example #19
0
 public void Play()
 {
     if (_mediaPlayer.Play())
     {
         if (_mediaPlayer.Position.TotalSeconds < 1)
         {
             OnStart?.Invoke(this);
         }
         OnPlay?.Invoke(this);
     }
 }
Example #20
0
    //string could be used for other levels
    public void Play(string input)
    {
        OnPlay?.Invoke();

        if (File.Exists(filePath))
        {
            Debug.Log("Deleting old save data");
            File.Delete(filePath);
        }
        else
        {
            Debug.Log("Starting fresh game");
        }

        SceneManager.LoadScene("Level1");
    }
Example #21
0
    public void Init(GameModesController gameModesController)
    {
        highScoreUI.Init();

        menuUI.OnPlay       += (duration, slots) => OnPlay?.Invoke(duration, slots);
        highScoreUI.OnClose += ToMenu;

        gameModesController.OnGameStart += ToPlay;
        gameModesController.OnGameEnd   += ToHighScores;

        menuUI.Deactivate();
        playUI.Deactivate();
        highScoreUI.Deactivate();

        ToMenu();
    }
Example #22
0
    public void Play()
    {
        Debug.Log("Drone has started");

        OnPlay?.Invoke(this);

        if (commands != null)
        {
            currentIndex = 0;

            LaunchCommand(currentIndex);
        }
        else
        {
            Debug.LogWarning("Drone has no command");

            OnEnd?.Invoke(this);
        }
    }
    public void Play()
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return;
        }
#endif
        if (Playing && !AllowMultiPlay)
        {
            return;
        }

        Playing = true;
        OnPlay.Invoke();
        if (secondsToAutoStop > 0)
        {
            this.InvokeAfter(Stop, secondsToAutoStop);
        }
    }
Example #24
0
        /// <summary>
        /// Starts <see cref="PlayedScript"/> playback at <paramref name="playlistIndex"/>.
        /// </summary>
        public void Play(int playlistIndex)
        {
            if (PlayedScript is null || Playlist is null)
            {
                Debug.LogError("Failed to start script playback: the script is not set.");
                return;
            }

            if (IsPlaying)
            {
                Stop();
            }

            PlayedIndex = playlistIndex;
            if (Playlist.IsIndexValid(PlayedIndex) || SelectNextCommand())
            {
                playRoutineCTS = new CancellationTokenSource();
                PlayRoutineAsync(playRoutineCTS.Token).WrapAsync();
                OnPlay?.Invoke();
            }
        }
 protected void InvokePlay(float time) => OnPlay?.Invoke(time);
Example #26
0
        public void Play()
        {
            OnPlay?.Invoke(this, new EventArgs());

            ExecuteCommandIfPossible(PlaybackStartedCommand);
        }
Example #27
0
 public void Play()
 {
     OnPlay?.Invoke();
 }
 public void Play(float delay) => OnPlay?.Invoke(-delay);
 public void Play() => OnPlay?.Invoke(0);
Example #30
0
 public static void InvokePlay()
 {
     OnPlay?.Invoke();
 }