RE: Events dont fire

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Anders Keis Hansen (akha99_at_online.nospam)
Date: 11/30/04


Date: Tue, 30 Nov 2004 03:23:04 -0800

Hi Rhett

you have to have a folder called c:\myfiles which contain an video clip with
sound

Else the code is here, i put in a comment i my problem area with the sound
in english. Here is the code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.AudioVideoPlayback;
using Microsoft.DirectX.DirectDraw;
using System.IO;
namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private string[] m_playlist = null;
private int maxindex = 0;
private int videoindex = 0;
private Video video;
private string videoPath = "C:\\myfiles";
private Timer mytimer;
private string mytest = "";
private string mainPath = "C:\\myfiles";
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_playlist = FillPlaylist();
PlayVideo();
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (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()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
//
// Form1
//
this.AutoScale = false;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.Desktop;
this.ClientSize = new System.Drawing.Size(1016, 720);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition =
System.Windows.Forms.FormStartPosition.WindowsDefaultBounds;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private string[] FillPlaylist()
{
// Sæt maxindex til antal videoer i path
maxindex = Directory.GetFiles(videoPath).Length;
if (maxindex <= 0)
{
MessageBox.Show("Der er ikke lagt billeder eller film ind i c:\\myfiles
kataloget, Dynamiks player lukkes ned");
}
// Lav playlisten
string[] playlist = new string[maxindex];
// udfyld playliste
playlist = Directory.GetFiles(videoPath);
// Returner string array
return playlist;
}
private void PlayVideo()
{
mytimer = new Timer();
try
{
mytest = m_playlist[0].Substring(m_playlist[0].Length-3,3);
if (mytest.ToLower() == "jpg")
{
mytimer.Interval = 10000;
mytimer.Enabled = true;
video = new Video(m_playlist[0]);//
video.Owner = this;
video.Size = new Size(1024,768);
video.HideCursor();
video.Play();
mytimer.Tick += new System.EventHandler (this.OnVideoEnding);
}
else
{
video = new Video(m_playlist[0]);
video.Ending += new EventHandler(this.OnVideoEnding);
video.Owner = this;
video.Size = new Size(1024,768);
video.HideCursor();
video.Play();
//If commented out, events fire on video.Edning
video.Audio.Volume = 0;
}
}
catch(Exception)
{
}
}
private void OnVideoEnding(object sender, System.EventArgs e)
{
mytimer.Stop();
// Check om Video kører
if(video != null)
{
// Forøg musikindex
videoindex++;
// Stop nuværende
//video.Stop();
if(videoindex >= maxindex)
{
videoindex = 0;
}
try
{
mytest = m_playlist[videoindex].Substring(m_playlist[videoindex].Length-3,3);
if (mytest.ToLower() == "jpg")
{
mytimer = new Timer();
mytimer.Interval = 10000;
mytimer.Enabled = true; // åbn næste video i array
video.Open(m_playlist[videoindex]);
// Reset Ending event
mytimer.Tick -= new EventHandler(this.OnVideoEnding);
mytimer.Tick += new EventHandler(this.OnVideoEnding);
// afspil
video.Owner = this;
video.Size = new Size(1024, 768);
video.HideCursor();
video.Play();
}
else
{
video.Open(m_playlist[videoindex]);
// Reset
video.Ending -= new EventHandler(this.OnVideoEnding);
video.Ending += new EventHandler(this.OnVideoEnding);
// afspil
video.Owner = this;
video.Size = new Size(1024, 768);
video.HideCursor();
video.Play();
}
}
catch(Exception)
{
// If they are any problems, exit the application
MessageBox.Show("Der lagt materiale ind som ikke understøttes af
afspilleren, *.avi,*.mpg,*.jpg,*.vob er gyldige formater, afspiller lukkes,
fjern venligst ugyldigt materiale fra myfiles kataloget");
}
}
}
}
}



Relevant Pages

  • Re: IRQ and Serial Ports
    ... private int cont;//informs the bill counter number ... private string nummaq;//keeps the machine number ... public void FechaPorta() ... private void SendBlock ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: to bind or not to bind that is the question?
    ... private System.Windows.Forms.ListView listView1; ... private void chooseControl ... SqlCeConnection con = new ... private string _CompanyName; ...
    (microsoft.public.dotnet.framework.compactframework)
  • problem with vmr9 image compositor - method Draw
    ... I play video with playlist, if i play video about 5x it is ... but so 6round of video playing throw exception int ... private void ConfigureVMR9InWindowlessMode() ... Surface renderTarget = new Surface; ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Morphy the math defective
    ... That's fine, but it's located somewhere private, where I ... Since you're being civil here I'll do the same for a post at least. ... The reason I did the video is because of the ridiculous claim you made ... Even after I proved to you that copy/paste works, you still denied it, ...
    (rec.gambling.poker)
  • Re: Morphy the math defective
    ... That's fine, but it's located somewhere private, where I ... to discuss things in a civil manner, and if proven wrong you still don't ... The reason I did the video is because of the ridiculous claim you made ... Even after I proved to you that copy/paste works, you still denied it, ...
    (rec.gambling.poker)