Beispiel #1
0
		/// <summary>
		/// Play a sequence of a given file name.
		/// </summary>
		/// <param name="sequence"></param>
		/// <returns></returns>
		public static ContextStatus PlaySequence(Sequence sequence){
			
			var status = new ContextStatus();

			if (sequence == null)
			{
				throw new ArgumentNullException("sequence");
			}

			IEnumerable<IContext> contexts = VixenSystem.Contexts.Where(x => x.Name.Equals(sequence.Name) && (x.IsRunning || x.IsPaused));

			if (contexts.Any(x => x.IsPaused))
			{
				foreach (var context in contexts)
				{
					if (context.IsPaused)
					{
						context.Resume();

					}
				}
				status.Message = string.Format("Resumed {0}", sequence.Name);

			}
			else
			{
				string fileName = HttpUtility.UrlDecode(sequence.FileName);

				ISequence seq = SequenceService.Instance.Load(fileName);
				if (seq != null)
				{
					Logging.Info(string.Format("Web - Prerendering effects for sequence: {0}", sequence.Name));
					Parallel.ForEach(seq.SequenceData.EffectData.Cast<IEffectNode>(), effectNode => effectNode.Effect.PreRender());

					ISequenceContext context = VixenSystem.Contexts.CreateSequenceContext(
						new ContextFeatures(ContextCaching.NoCaching), seq);
					context.ContextEnded += context_ContextEnded;
					context.Play(TimeSpan.Zero, seq.Length);
					status.State = ContextStatus.States.Playing;
					status.Sequence = new Sequence()
					{
						Name = context.Sequence.Name,
						FileName = fileName
					};
					
					status.Message = string.Format("Playing sequence {0} of length {1}", sequence.Name, seq.Length);
				}
				else
				{
					status.Message = string.Format("Sequence {0} not found.", fileName);
				}
				
				
			}
			

			return status;
		}
Beispiel #2
0
		private void UpdateContextStatus(object state)
		{
			_contextStatuses.Clear();
			foreach (var context in VixenSystem.Contexts)
			{
				if (@"Web Server".Equals(context.Name))
				{
					//Skip the web server context.
					continue;
				}

				
				var status = new ContextStatus()
				{
					Sequence = new Sequence()
					{
						Name = context.Name	
					},
					Position = context.GetTimeSnapshot()
				};

				var sequenceContext = context as ISequenceContext;
				if (sequenceContext != null)
				{
					status.Sequence.FileName =  Path.GetFileName(sequenceContext.Sequence.FilePath);
				}

				if (context.IsPaused)
				{
					status.State = ContextStatus.States.Paused;

				}
				else if (context.IsRunning)
				{
					status.State = ContextStatus.States.Playing;
				}
				else
				{
					status.State = ContextStatus.States.Stopped;
					status.Position = TimeSpan.Zero; //Ensure reported time is set to zero when context is stopped
				}

				_contextStatuses.Add(status);
			}
			BroadcastContextStates();
		}
Beispiel #3
0
        /// <summary>
        /// Pause the current playing sequence.
        /// </summary>
        /// <returns>Status</returns>
        public static ContextStatus PauseSequence(Sequence sequence)
        {
            var status = new ContextStatus();
            IEnumerable<IContext> contexts = VixenSystem.Contexts.Where(x => x.Name.Equals(sequence.Name) && (x.IsRunning || x.IsPaused));

            if (!contexts.Any())
            {
                status.Message = "Sequence not found.";
            }
            else
            {
                foreach (var context in contexts)
                {
                    if (context.IsRunning)
                    {
                        context.Pause();
                    }
                }
                status.Message = string.Format(@"Sequence {0} paused.", sequence.Name);
            }

            return status;
        }