예제 #1
0
        public override void ActivateResource(ResourceActivationContext context, SavePoint resource)
        {
            if (!context.IsClosed)
            {
                var time = context.Retrieve <string>();

                if (time == null)
                {
                    context.Store(DateTime.Now.ToString());

                    SavePointManager.Instance.ActivateSavePoint(context, resource);
                }

                context.Close();
            }

            base.ActivateResource(context, resource);
        }
예제 #2
0
        public bool StopPlaying(ResourceActivationContext activationContext, bool interrupt = false)
        {
            PlayerContext ctxt = null;

            lock (m_onUnpause)
            {
                m_onUnpause.Remove(activationContext.InstanceId);
            }

            if (m_playablePlayers.TryGetValue(activationContext.InstanceId, out ctxt))
            {
                var player = ctxt.Player;

                activationContext.Store(new PlaybackContext(player.Position));

                m_playablePlayers.Remove(activationContext.InstanceId);

                // FIX:: SOUNDTRACK LOCK OBJECT.
                lock (SoundtrackLockObject)
                {
                    if (m_soundtrackPlayers.Contains(ctxt))
                    {
                        var origSoundtrackPlayer = CurrentSoundtrackPlayer;

                        m_soundtrackPlayers.Remove(ctxt);

                        if (m_isPlayingSoundtrack)
                        {
                            if (origSoundtrackPlayer == ctxt)
                            {
                                // If we just removed the currently playing
                                // soundtrack player
                                Fader.FadeOut(origSoundtrackPlayer.Player, TimeSpan.FromSeconds(FadeDuration),
                                              () =>
                                {
                                    origSoundtrackPlayer.Player.Dispose();
                                });

                                if (CurrentSoundtrackPlayer != null)
                                {
                                    FadeInSoundtrack(CurrentSoundtrackPlayer);
                                }
                            }
                            else
                            {
                                player.Dispose();
                            }
                        }
                        else
                        {
                            player.Dispose();
                        }
                    }
                    else
                    {
                        if (IsPaused || interrupt || player != CurrentNarratorPlayer)
                        {
                            // Don't immediately dispose if this is the current narrator player: let
                            // the narrator audio complete on its own.
                            player.Dispose();
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }