473,507 Members | 3,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to launch event after form load

In my Win app, I'm needing to load a media file into my Windows Media Player
control, and THEN read an attribute from the file.

The thing is, the file has to be playing for a split second before the
attribute can be read.

I can have wmpPlayer.URL = @"D:\Web\FWT\TestFile.wma"; in my form load event
and then a button on the form to get the value I need...

label1.Text = wmpPlayer.currentMedia.getItemInfo("Abstract");

But I don't want to have to manually click a button. I want the form to
load, start playing the file, and then somehow trigger an event to go and
get the attribute.

Thanks for any help.
Ron

Jan 23 '07 #1
3 9706
Hi,
You could use a timer and then have the Tick event update the label
after a second or so.

HTH,
James.

Ronald S. Cook wrote:
In my Win app, I'm needing to load a media file into my Windows Media Player
control, and THEN read an attribute from the file.

The thing is, the file has to be playing for a split second before the
attribute can be read.

I can have wmpPlayer.URL = @"D:\Web\FWT\TestFile.wma"; in my form load event
and then a button on the form to get the value I need...

label1.Text = wmpPlayer.currentMedia.getItemInfo("Abstract");

But I don't want to have to manually click a button. I want the form to
load, start playing the file, and then somehow trigger an event to go and
get the attribute.

Thanks for any help.
Ron
Jan 23 '07 #2
Hi,

"Ronald S. Cook" <rc***@westinis.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

| But I don't want to have to manually click a button. I want the form to
| load, start playing the file, and then somehow trigger an event to go and
| get the attribute.

A timer?
--
Ignacio Machin
machin AT laceupsolutions com
Jan 23 '07 #3
Hi Ron,

After you start the player, try calling System.Threading.Thread.Sleep(500),
but with the desired wait time in milliseconds (my example is 1/2 second).
Then you can retrieve the attribute.

If the player is running on the executing thread than you'll have to wait
asynchronously. Maybe a bit convoluted, but here's one solution:

// 2.0 framework syntax

System.Threading.SynchronizationContext context =
System.Threading.SynchronizationContext.Current;

MethodInvoker invoker = new MethodInvoker(delegate()
{
// this code will run asynchronously
System.Threading.Thread.Sleep(500);

context.Send(delegate(object state)
{
// this code will run on the main UI thread
// TODO: retrieve value
}, null);
});

// TODO: start player

invoker.BeginInvoke(delegate(IAsyncResult result)
{
invoker.EndInvoke(result);
}, null);
--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in VS IDE)

"Ronald S. Cook" <rc***@westinis.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
In my Win app, I'm needing to load a media file into my Windows Media
Player control, and THEN read an attribute from the file.

The thing is, the file has to be playing for a split second before the
attribute can be read.

I can have wmpPlayer.URL = @"D:\Web\FWT\TestFile.wma"; in my form load
event and then a button on the form to get the value I need...

label1.Text = wmpPlayer.currentMedia.getItemInfo("Abstract");

But I don't want to have to manually click a button. I want the form to
load, start playing the file, and then somehow trigger an event to go and
get the attribute.

Thanks for any help.
Ron

Jan 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
4065
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
7
404
by: Tammy | last post by:
How do I launch a form from within another? The book I have only talks about MDI forms and I know that there should be a way to do that without the MDI form.
5
4283
by: RickDee | last post by:
Please help, anybody. I am trying to write a program so that it can launch an exe file ( which is also genereated in C# ) and then simulate the button clicking and invoke the methods inside the...
6
6007
by: Robert Werner | last post by:
I want to write one general purpose set of code that will handle the population (where required) of all controls on a form. Though I'm new to C# my instinct is to somehow hook into the Load event...
0
2500
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind...
6
3350
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
3
2714
by: Dennis | last post by:
I have the following code for showing a form: dim frm as new myForm frm.ShowDialog (The Form Load Event is fired then I hide the form using Me.Hide when the X in the UR corner is clicked). ...
2
2928
by: Franky | last post by:
Threre is a Form containing a usercontrol In the form's Load event it references a usercontrol property, say, zz The first showdialog(formx) causes 1 usercontrol_load event 2 form_load event...
9
2236
by: kimiraikkonen | last post by:
Hello experts, That's very very simple question but i wonder if you can help: I have form1 and a button which brings user to form2 when button is clicked, and i have a web-browser (.net 2.0...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.