473,666 Members | 1,991 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\Te stFile.wma"; in my form load event
and then a button on the form to get the value I need...

label1.Text = wmpPlayer.curre ntMedia.getItem Info("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 9716
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\Te stFile.wma"; in my form load event
and then a button on the form to get the value I need...

label1.Text = wmpPlayer.curre ntMedia.getItem Info("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******** ********@TK2MSF TNGP06.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.Threadin g.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.Threadin g.Synchronizati onContext context =
System.Threadin g.Synchronizati onContext.Curre nt;

MethodInvoker invoker = new MethodInvoker(d elegate()
{
// this code will run asynchronously
System.Threadin g.Thread.Sleep( 500);

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

// TODO: start player

invoker.BeginIn voke(delegate(I AsyncResult result)
{
invoker.EndInvo ke(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******** ********@TK2MSF TNGP06.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\Te stFile.wma"; in my form load
event and then a button on the form to get the value I need...

label1.Text = wmpPlayer.curre ntMedia.getItem Info("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
4093
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 the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
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
4306
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 exe. The button clicking part is working fine, but I just cannot get the method call. Here is my program snippet. **************************************************************
6
6012
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 of the Control class, as this should get inherited down to all of the controls. Two questions: 1. Is this possible? 2. What's the simplest, most elegant way to do it?
0
2514
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 of an aspx page and the presentation of the page to the user? 2~ is it true that the engine takes data from the Request.Form and puts them
6
3369
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 the usual stuff of recreating the usercontrol in the Page Init event. The 'failure' sequence is as follows: - select web form button to display the user control - select user control button, event fires - select web form button to display...
3
2728
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). 'Do something in code frm.ShowDialog (The Form Load Event fires again)
2
2940
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 which causes zz as expected the second showdialog(formx) causes 1 form_load event which causes zz as expected
9
2245
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 component) control placed in form2 which is coded to run when form2 is loaded: Form1 has only a button brings user to second form, form1 has that code:
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5664
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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 we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.