Beispiel #1
0
 internal void RaiseOnPlay(string sender = null, XBMCRPC.Player.Notifications.Data data = null)
 {
     if (OnPlay != null)
     {
         OnPlay.BeginInvoke(sender, data, null, null);
     }
 }
Beispiel #2
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;
            }
        }
Beispiel #3
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();
            }
        }
Beispiel #4
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();
    }
Beispiel #5
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());
                }
            }
        }
Beispiel #6
0
 internal void RaiseOnPlay(string sender = null, Data data = null)
 {
     if (OnPlay != null)
     {
         OnPlay.BeginInvoke(sender, data, null, null);
     }
 }
Beispiel #7
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();
    }
        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();
        }
Beispiel #9
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());
            }
        }
        protected override void Start()
        {
            base.Start();

            btnPlay?.onClick.RemoveAllListeners();
            btnPlay?.onClick.AddListener(() => OnPlay?.Invoke());
        }
Beispiel #11
0
 public async void RaiseOnPlay(double duration)
 {
     if (OnPlay != null)
     {
         await OnPlay.Invoke(duration);
     }
 }
Beispiel #12
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);*/
        }
Beispiel #13
0
 public void Play()
 {
     if (player != null && player.isPrepared)
     {
         OnPlay?.Invoke();
         player.Play();
     }
 }
Beispiel #14
0
        public void OnPlayCallback(int soundId, int durationInSeconds)
        {
            TotalTime = TimeSpan.FromSeconds(durationInSeconds);

            OnPlay?.Invoke(new HowlPlayEventArgs {
                SoundId = soundId, TotalTime = TotalTime
            });
        }
Beispiel #15
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);
        }
Beispiel #16
0
        private void OnPlayButton_Clicked()
        {
            if (selectedSquads.Count > 0)
            {
                OnPlay?.Invoke(selectedPatterns);
            }

            PlayImportantClickSound();
        }
Beispiel #17
0
 public void Play()
 {
     if (_player.IsPlaying())
     {
         return;
     }
     OnPlay?.Invoke();
     _player.Play();
 }
Beispiel #18
0
 private static void Player_CurrentStateChanged(MediaPlayer sender, object args)
 {
     if (Player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
     {
         Invoke(() => OnPlay?.Invoke());
     }
     else
     {
         Invoke(() => OnPause?.Invoke());
     }
 }
Beispiel #19
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
            });
        }
Beispiel #20
0
 public void ResumePlaying()
 {
     if (OnPlay != null)
     {
         OnPlay.Invoke(Sound, this);
     }
     HideAll();
     BtnPause.gameObject.SetActive(true);
     Progress.gameObject.SetActive(true);
     Progress.value = 0;
 }
Beispiel #21
0
 public void Play()
 {
     if (_mediaPlayer.Play())
     {
         if (_mediaPlayer.Position.TotalSeconds < 1)
         {
             OnStart?.Invoke(this);
         }
         OnPlay?.Invoke(this);
     }
 }
Beispiel #22
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");
    }
Beispiel #23
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();
    }
Beispiel #24
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);
        }
    }
Beispiel #26
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);
Beispiel #28
0
        public void Play()
        {
            OnPlay?.Invoke(this, new EventArgs());

            ExecuteCommandIfPossible(PlaybackStartedCommand);
        }
Beispiel #29
0
 public void Play()
 {
     OnPlay?.Invoke();
 }
 public void Play(float delay) => OnPlay?.Invoke(-delay);