Jump to content

Welcome to MCE-Community.de
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

[CodeSample]ActiveStreamClient

- - - - -

  • This topic is locked This topic is locked
No replies to this topic

#1
ehemaliges Mitglied

ehemaliges Mitglied

    Inventar

  • Mitglied
  • PipPipPipPipPipPipPip
  • 6,559 posts
  • Geschlecht:Männlich
  • Interessen:c# Mcml
Attached File  ActiveStream_ClientViewb.PNG   506.16K   104 downloads

denke das Bildchen verrät schon etwas worum es geht

richtig es ist ein kleiner Client womit man laufende Tv Server Streams schauen kann

wie funktioniert er ? Gute frage aber er ist so simple gestrickt das jeder damit klar kommen sollte ( hoffe ich zumindest )

wenn man kein mediaportal installiert hat muss man

1. einen filter ( TsReader.ax )registrieren mit regsvr32 ( bei Vista und Windows 7 sind Adminrechte erforderlich )

2. eine kleine Regfile ausführen damit das Protokoll rtsp nutzbar wird

3. wenn kein Activer Tv Stream vom Tv Server anliegt ,einen starten ( Tv Server Config unter Manual Control )

4. den mini Client starten rechte maustaste und auf Open Stream klicken

Attached File  ActiveStream_Client_URL.PNG   54.95K   72 downloads

5. die rtsp Url vom Activen Tv Server Stream angeben und Ok klicken

Attached File  ActiveStream_Client_URLb.PNG   59.2K   66 downloads

daraufhin sollte der stream wiedergegeben werden man kann ihn pausieren stoppen und wieder starten wie man möchte
Attached File  ActiveStream_ClientViewb.PNG   506.16K   104 downloads

Source und Binäries

Für die User die es nicht downloaden wollen aber denn noch den Code einsehen möchten

Form1.cs

Form1.cs

using System;
using System.Windows.Forms;
using QuartzTypeLib;

namespace ActiveStreamClient
{
	public partial class Form1 : Form
	{


		public Form1()
		{
			InitializeComponent();
		}
		private const int WS_CHILD = 0x40000000;
		private const int WS_CLIPCHILDREN = 0x2000000;

		private IMediaControl mediacontrol = null;
		private IVideoWindow videowindow = null;


		private void OpenStreamTSMI_Click(object sender, EventArgs e)
		{
			StreamUrlDialog dlg = new StreamUrlDialog();
			if (DialogResult.OK == dlg.ShowDialog())
			{
				if (mediacontrol != null) mediacontrol.Stop();

				FilgraphManager graphmanager = new FilgraphManager();
				graphmanager.RenderFile(dlg.URL);
				try
				{
					videowindow = (IVideoWindow)graphmanager;
					videowindow.Owner = (int)VideoPanel.Handle;
					videowindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
					videowindow.SetWindowPosition(VideoPanel.ClientRectangle.Left, VideoPanel.ClientRectangle.Top, VideoPanel.ClientRectangle.Width, VideoPanel.ClientRectangle.Height);
				}
				catch
				{
					

				}
				mediacontrol = (IMediaControl)graphmanager;
				mediacontrol.Run();
				this.Text = "Active Tv Server Stream - [" + dlg.URL + "]";
				 
			}
		}

		private void VideoPanel_SizeChanged(object sender, EventArgs e)
		{
			if (videowindow != null)
			{
				try
				{
					videowindow.SetWindowPosition(VideoPanel.ClientRectangle.Left,
						VideoPanel.ClientRectangle.Top,
						VideoPanel.ClientRectangle.Width,
						VideoPanel.ClientRectangle.Height);
				}
				catch
				{

				}


			}
		}

		private void PlayTSMI_Click(object sender, EventArgs e)
		{
			mediacontrol.Run();
		}

		private void PauseTSMI_Click(object sender, EventArgs e)
		{
			mediacontrol.Pause();
		}

		private void StopTSMI_Click(object sender, EventArgs e)
		{
			mediacontrol.Stop();
		}


	}
}

Form1.Designer.cs
namespace ActiveStreamClient
{
	partial class Form1
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
			this.OpenStreamTSMI = new System.Windows.Forms.ToolStripMenuItem();
			this.Separator1 = new System.Windows.Forms.ToolStripSeparator();
			this.PlayTSMI = new System.Windows.Forms.ToolStripMenuItem();
			this.PauseTSMI = new System.Windows.Forms.ToolStripMenuItem();
			this.StopTSMI = new System.Windows.Forms.ToolStripMenuItem();
			this.Separator2 = new System.Windows.Forms.ToolStripSeparator();
			this.VideoPanel = new System.Windows.Forms.Panel();
			this.contextMenuStrip1.SuspendLayout();
			this.SuspendLayout();
			// 
			// contextMenuStrip1
			// 
			this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
			this.OpenStreamTSMI,
			this.Separator1,
			this.PlayTSMI,
			this.PauseTSMI,
			this.StopTSMI,
			this.Separator2});
			this.contextMenuStrip1.Name = "contextMenuStrip1";
			this.contextMenuStrip1.Size = new System.Drawing.Size(144, 104);
			// 
			// OpenStreamTSMI
			// 
			this.OpenStreamTSMI.Name = "OpenStreamTSMI";
			this.OpenStreamTSMI.Size = new System.Drawing.Size(143, 22);
			this.OpenStreamTSMI.Text = "Open Stream";
			this.OpenStreamTSMI.Click += new System.EventHandler(this.OpenStreamTSMI_Click);
			// 
			// Separator1
			// 
			this.Separator1.Name = "Separator1";
			this.Separator1.Size = new System.Drawing.Size(140, 6);
			// 
			// PlayTSMI
			// 
			this.PlayTSMI.Name = "PlayTSMI";
			this.PlayTSMI.Size = new System.Drawing.Size(143, 22);
			this.PlayTSMI.Text = "Play";
			this.PlayTSMI.Click += new System.EventHandler(this.PlayTSMI_Click);
			// 
			// PauseTSMI
			// 
			this.PauseTSMI.Name = "PauseTSMI";
			this.PauseTSMI.Size = new System.Drawing.Size(143, 22);
			this.PauseTSMI.Text = "Pause";
			this.PauseTSMI.Click += new System.EventHandler(this.PauseTSMI_Click);
			// 
			// StopTSMI
			// 
			this.StopTSMI.Name = "StopTSMI";
			this.StopTSMI.Size = new System.Drawing.Size(143, 22);
			this.StopTSMI.Text = "Stop";
			this.StopTSMI.Click += new System.EventHandler(this.StopTSMI_Click);
			// 
			// Separator2
			// 
			this.Separator2.Name = "Separator2";
			this.Separator2.Size = new System.Drawing.Size(140, 6);
			// 
			// VideoPanel
			// 
			this.VideoPanel.BackColor = System.Drawing.Color.Black;
			this.VideoPanel.ContextMenuStrip = this.contextMenuStrip1;
			this.VideoPanel.Dock = System.Windows.Forms.DockStyle.Fill;
			this.VideoPanel.Location = new System.Drawing.Point(0, 0);
			this.VideoPanel.Name = "VideoPanel";
			this.VideoPanel.Size = new System.Drawing.Size(704, 538);
			this.VideoPanel.TabIndex = 1;
			this.VideoPanel.SizeChanged += new System.EventHandler(this.VideoPanel_SizeChanged);
			// 
			// Form1
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(704, 538);
			this.Controls.Add(this.VideoPanel);
			this.Name = "Form1";
			this.contextMenuStrip1.ResumeLayout(false);
			this.ResumeLayout(false);

		}

		#endregion

		private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
		private System.Windows.Forms.ToolStripMenuItem OpenStreamTSMI;
		private System.Windows.Forms.Panel VideoPanel;
		private System.Windows.Forms.ToolStripMenuItem PlayTSMI;
		private System.Windows.Forms.ToolStripMenuItem PauseTSMI;
		private System.Windows.Forms.ToolStripMenuItem StopTSMI;
		private System.Windows.Forms.ToolStripSeparator Separator1;
		private System.Windows.Forms.ToolStripSeparator Separator2;
	}
}

StreamOpenDialog.cs
using System;
using System.Windows.Forms;

namespace ActiveStreamClient
{
	public partial class StreamUrlDialog : Form
	{
		
		public StreamUrlDialog()
		{
			InitializeComponent();
		}
		private string _URL;

		public string URL
		{
			get
			{
				return _URL;
			}
			set
			{
				_URL = value;
				StreamUrlTextbox.Text = _URL;
			}
		}

		private void OkButton_Click(object sender, EventArgs e)
		{
			_URL = StreamUrlTextbox.Text;
			DialogResult = DialogResult.OK;
		}

		private void CaneltButton_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.Cancel;
		}
	}
}


StreamOpenDialog.Designer.cs
namespace ActiveStreamClient
{
	partial class StreamUrlDialog
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.OkButton = new System.Windows.Forms.Button();
			this.CaneltButton = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.StreamUrlTextbox = new System.Windows.Forms.TextBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// OkButton
			// 
			this.OkButton.Location = new System.Drawing.Point(216, 77);
			this.OkButton.Name = "OkButton";
			this.OkButton.Size = new System.Drawing.Size(75, 23);
			this.OkButton.TabIndex = 0;
			this.OkButton.Text = "Ok";
			this.OkButton.UseVisualStyleBackColor = true;
			this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
			// 
			// CaneltButton
			// 
			this.CaneltButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.CaneltButton.Location = new System.Drawing.Point(297, 77);
			this.CaneltButton.Name = "CaneltButton";
			this.CaneltButton.Size = new System.Drawing.Size(75, 23);
			this.CaneltButton.TabIndex = 1;
			this.CaneltButton.Text = "Cancel";
			this.CaneltButton.UseVisualStyleBackColor = true;
			this.CaneltButton.Click += new System.EventHandler(this.CaneltButton_Click);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(6, 22);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(47, 13);
			this.label1.TabIndex = 2;
			this.label1.Text = "Source :";
			// 
			// StreamUrlTextbox
			// 
			this.StreamUrlTextbox.Location = new System.Drawing.Point(53, 19);
			this.StreamUrlTextbox.Name = "StreamUrlTextbox";
			this.StreamUrlTextbox.Size = new System.Drawing.Size(301, 20);
			this.StreamUrlTextbox.TabIndex = 3;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.StreamUrlTextbox);
			this.groupBox1.Location = new System.Drawing.Point(12, 12);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(360, 56);
			this.groupBox1.TabIndex = 4;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Please Enter the Stream Url";
			// 
			// StreamUrlDialog
			// 
			this.AcceptButton = this.OkButton;
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.CancelButton = this.CaneltButton;
			this.ClientSize = new System.Drawing.Size(384, 112);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.CaneltButton);
			this.Controls.Add(this.OkButton);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.HelpButton = true;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "StreamUrlDialog";
			this.ShowIcon = false;
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			this.ResumeLayout(false);

		}

		#endregion

		private System.Windows.Forms.Button OkButton;
		private System.Windows.Forms.Button CaneltButton;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox StreamUrlTextbox;
		private System.Windows.Forms.GroupBox groupBox1;
	}
}

Projects :






ForTheRecord / ArgusTV MCE Client

ForTheRecord Current version 1.0.0.2

ArgusTV Current Version 2.0.1.0


SimpleRadio








0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users