Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: Control Box Color Pin
half-life15-Jul-09 19:30
half-life15-Jul-09 19:30 
GeneralRe: Control Box Color Pin
Henry Minute16-Jul-09 2:08
Henry Minute16-Jul-09 2:08 
GeneralRe: Control Box Color Pin
half-life16-Jul-09 20:40
half-life16-Jul-09 20:40 
AnswerRe: Control Box Color Pin
Dave Kreskowiak13-Jul-09 4:36
mveDave Kreskowiak13-Jul-09 4:36 
GeneralRe: Control Box Color Pin
half-life15-Jul-09 19:29
half-life15-Jul-09 19:29 
GeneralRe: Control Box Color Pin
Dave Kreskowiak16-Jul-09 15:55
mveDave Kreskowiak16-Jul-09 15:55 
GeneralRe: Control Box Color Pin
half-life16-Jul-09 20:42
half-life16-Jul-09 20:42 
Questionmedia not adding to play list Pin
uglyeyes13-Jul-09 1:52
uglyeyes13-Jul-09 1:52 
Hi!

below is my codes. I am trying to play all the files in a playlist but it only plays one and stops

[STAThread]
static void Main()
{

Application.Run(new Form1());
Form1 frm = new Form1();
frm.queueMedia();


}
private void queueMedia()
{
string mediasource = "C:\\Test\\Media";
string[] filenames = Directory.GetFiles(mediasource);
foreach (string filename in filenames)
{
PlayMedia(filename);
}
}
private void PlayMedia(string filename)
{
CleanUp();

m_objFilterGraph = new FilgraphManager();
m_objFilterGraph.RenderFile(filename);

m_objBasicAudio = m_objFilterGraph as IBasicAudio;

try
{
m_objVideoWindow = m_objFilterGraph as IVideoWindow;
m_objVideoWindow.Owner = (int)panel1.Handle;
m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
catch (Exception)
{
m_objVideoWindow = null;
}

m_objMediaEvent = m_objFilterGraph as IMediaEvent;

m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
m_objMediaEventEx.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0);

m_objMediaPosition = m_objFilterGraph as IMediaPosition;

m_objMediaControl = m_objFilterGraph as IMediaControl;

this.Text = "DirectShow - [" + filename + "]";

m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;

UpdateStatusBar();
UpdateToolBar();
}


private void CleanUp()
{
if (m_objMediaControl != null)
m_objMediaControl.Stop();

m_CurrentStatus = MediaStatus.Stopped;

if (m_objMediaEventEx != null)
m_objMediaEventEx.SetNotifyWindow(0, 0, 0);

if (m_objVideoWindow != null)
{
m_objVideoWindow.Visible = 0;
m_objVideoWindow.Owner = 0;
}

if (m_objMediaControl != null) m_objMediaControl = null;
if (m_objMediaPosition != null) m_objMediaPosition = null;
if (m_objMediaEventEx != null) m_objMediaEventEx = null;
if (m_objMediaEvent != null) m_objMediaEvent = null;
if (m_objVideoWindow != null) m_objVideoWindow = null;
if (m_objBasicAudio != null) m_objBasicAudio = null;
if (m_objFilterGraph != null) m_objFilterGraph = null;
}

private void menuItem4_Click(object sender, System.EventArgs e)
{
this.Close();
}

private void Form1_SizeChanged(object sender, System.EventArgs e)
{
if (m_objVideoWindow != null)
{
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
}

private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;
break;

case 1: m_objMediaControl.Pause();
m_CurrentStatus = MediaStatus.Paused;
break;

case 2: m_objMediaControl.Stop();
m_objMediaPosition.CurrentPosition = 0;
m_CurrentStatus = MediaStatus.Stopped;
break;
}

UpdateStatusBar();
UpdateToolBar();
}

protected override void WndProc( ref Message m)
{
if (m.Msg == WM_GRAPHNOTIFY)
{
int lEventCode;
int lParam1, lParam2;

while (true)
{
try
{
m_objMediaEventEx.GetEvent(out lEventCode,
out lParam1,
out lParam2,
0);

m_objMediaEventEx.FreeEventParams(lEventCode, lParam1, lParam2);

if (lEventCode == EC_COMPLETE)
{
m_objMediaControl.Stop();
m_objMediaPosition.CurrentPosition = 0;
m_CurrentStatus = MediaStatus.Stopped;
UpdateStatusBar();
UpdateToolBar();
}
}
catch (Exception)
{
break;
}
}
}

base.WndProc(ref m);
}

private void timer1_Tick(object sender, System.EventArgs e)
{
if (m_CurrentStatus == MediaStatus.Running)
{
UpdateStatusBar();
}
}

private void UpdateStatusBar()
{
switch (m_CurrentStatus)
{
case MediaStatus.None : statusBarPanel1.Text = "Stopped"; break;
case MediaStatus.Paused : statusBarPanel1.Text = "Paused "; break;
case MediaStatus.Running: statusBarPanel1.Text = "Running"; break;
case MediaStatus.Stopped: statusBarPanel1.Text = "Stopped"; break;
}

if (m_objMediaPosition != null)
{
int s = (int) m_objMediaPosition.Duration;
int h = s / 3600;
int m = (s - (h * 3600)) / 60;
s = s - (h * 3600 + m * 60);

statusBarPanel2.Text = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);

s = (int) m_objMediaPosition.CurrentPosition;
h = s / 3600;
m = (s - (h * 3600)) / 60;
s = s - (h * 3600 + m * 60);

statusBarPanel3.Text = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
}
else
{
statusBarPanel2.Text = "00:00:00";
statusBarPanel3.Text = "00:00:00";
}
}

private void UpdateToolBar()
{
switch (m_CurrentStatus)
{
case MediaStatus.None : toolBarButton1.Enabled = false;
toolBarButton2.Enabled = false;
toolBarButton3.Enabled = false;
break;

case MediaStatus.Paused : toolBarButton1.Enabled = true;
toolBarButton2.Enabled = false;
toolBarButton3.Enabled = true;
break;

case MediaStatus.Running: toolBarButton1.Enabled = false;
toolBarButton2.Enabled = true;
toolBarButton3.Enabled = true;
break;

case MediaStatus.Stopped: toolBarButton1.Enabled = true;
toolBarButton2.Enabled = false;
toolBarButton3.Enabled = false;
break;
}
}

private void menuItem5_Click(object sender, System.EventArgs e)
{
Form2 dlg = new Form2();
dlg.ShowDialog();
}
}

please help
AnswerRe: media not adding to play list Pin
Anindya Chatterjee13-Jul-09 2:09
Anindya Chatterjee13-Jul-09 2:09 
GeneralRe: media not adding to play list Pin
uglyeyes13-Jul-09 2:22
uglyeyes13-Jul-09 2:22 
GeneralRe: media not adding to play list Pin
Anindya Chatterjee13-Jul-09 2:57
Anindya Chatterjee13-Jul-09 2:57 
GeneralRe: media not adding to play list [modified] Pin
uglyeyes13-Jul-09 4:01
uglyeyes13-Jul-09 4:01 
GeneralRe: media not adding to play list Pin
uglyeyes13-Jul-09 17:54
uglyeyes13-Jul-09 17:54 
GeneralRe: media not adding to play list Pin
uglyeyes14-Jul-09 13:39
uglyeyes14-Jul-09 13:39 
GeneralRe: media not adding to play list Pin
uglyeyes14-Jul-09 17:05
uglyeyes14-Jul-09 17:05 
Questionhow to generate 0's and 1's only through Random Class... Pin
spalanivel13-Jul-09 1:47
spalanivel13-Jul-09 1:47 
AnswerRe: how to generate 0's and 1's only through Random Class... Pin
Anindya Chatterjee13-Jul-09 2:02
Anindya Chatterjee13-Jul-09 2:02 
GeneralRe: how to generate 0's and 1's only through Random Class... Pin
spalanivel13-Jul-09 2:13
spalanivel13-Jul-09 2:13 
GeneralRe: how to generate 0's and 1's only through Random Class... Pin
Anindya Chatterjee13-Jul-09 2:48
Anindya Chatterjee13-Jul-09 2:48 
AnswerRe: how to generate 0's and 1's only through Random Class... Pin
Luc Pattyn13-Jul-09 3:01
sitebuilderLuc Pattyn13-Jul-09 3:01 
QuestionHow to Use PropertyGrid for Complex Class Pin
Anindya Chatterjee13-Jul-09 1:45
Anindya Chatterjee13-Jul-09 1:45 
AnswerRe: How to Use PropertyGrid for Complex Class Pin
Henry Minute13-Jul-09 3:13
Henry Minute13-Jul-09 3:13 
GeneralRe: How to Use PropertyGrid for Complex Class Pin
Anindya Chatterjee13-Jul-09 3:16
Anindya Chatterjee13-Jul-09 3:16 
QuestionUpdating Text File Pin
vishal moharikar13-Jul-09 1:27
vishal moharikar13-Jul-09 1:27 
AnswerRe: Updating Text File Pin
musefan13-Jul-09 4:00
musefan13-Jul-09 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.