|
-
Jan 24th, 2007, 09:37 AM
#1
Thread Starter
Frenzied Member
[2005] Any likely difference between these two time/performance wise?
I'm in the middle of writing an app to control an eye-tracker using the SDK from the manufacturer. I have a form with a windows media player control on it.
What needs to happen is that there's a countdown (displayed on a label) as to when the video will play. On zero the video should start playing the avi file and the eye tracker should begin collecting gaze data.
My questions are, which of these would be better to use (or are they both the same performance wise) and secondly, is the slight pause as the video file loads in media player avoidable so that it starts right on zero?
VB Code:
Private Sub MediaPlayer_StateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) _
Handles mPlayer.PlayStateChange
If mPlayer.playState = WMPLib.WMPPlayState.wmppsPlaying Then
'Begin eye tracking here???
End If
End Sub
Or:
VB Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
intCount -= 1
If Not intCount = 0 Then
Me.lblCount.Text = "Showing in: " & intCount.ToString
Else
Timer1.Enabled = False
Me.lblCount.Visible = False
'Show video:
mPlayer.URL = Application.StartupPath & "\Cases\JEPIFWEJ_LKL003.avi"
'Or begin eye tracking here ???
End If
End Sub
Last edited by stimbo; Jan 24th, 2007 at 09:49 AM.
-
Jan 24th, 2007, 10:02 AM
#2
Re: [2005] Any likely difference between these two time/performance wise?
I doubt you would see any difference between the two. However, if you are using the timer to decrement the label, if the first option is to handle an event that will still be raised in the second option, then I think the second option could be slightly faster. Very unlikely to make a difference, though.
However, if you don't want that delay as the video loads, then the video has to be loaded by the time the counter reaches 0. There are two possible ways to do this. One is to preload it, and the other is to load it in a background thread. The first option would incur the cost early, the second option would be a bit more complicated. Take your pick.
My usual boring signature: Nothing
 
-
Jan 24th, 2007, 10:17 AM
#3
Thread Starter
Frenzied Member
Re: [2005] Any likely difference between these two time/performance wise?
I take it a background thread would be something like using the background worker? I don't have any experience with it really but had a quick look on MSDN and doesn't look overly complicated.... (I know....I've just cursed myself)
When you say pre-load it, does the media player control have an option somewhere for that? I was looking for some kind of buffer option but couldn't find anything. Does one exist? Or is somekind of filestream type thing needed? I thought about adding the videos to a mediaplayer collection or adding the list of videos to a playlist but I don't actually think that would make any difference in terms of preloading. Just need some clarification really.
Thanks,
-
Jan 24th, 2007, 12:47 PM
#4
Re: [2005] Any likely difference between these two time/performance wise?
The background thread is not all that difficult to implement, nor is it difficult...in concept. The problems that multithreading present can generally be lumped into these categories:
1)Interaction issues
2) Debugging issues
The background thread is almost like a separate program, but it might use/change the same variables the main thread is using. You simply need to be careful if you have a varialbe being used by the two, because it wouldn't be good having one thread changing a variable while another thread is reading it. If the two processes are very dissimilar, as it appears they would be in your case, these issues probably don't arise.
Debugging an error on a background thread can be a royal pain in the butt. If you put a breakpoint in either thread, the other thread won't be pausing, so it can be more difficult debugging when one thread goes ahead and completes while you are wandering around in the other thread. If the problem you are trying to fix deals with synchronization between the two threads, this can be a pain.
I haven't worked wtiht the media player control, so I can't say whether you can preload, but it seems like you ought to be able to.
My usual boring signature: Nothing
 
-
Jan 24th, 2007, 01:06 PM
#5
Thread Starter
Frenzied Member
Re: [2005] Any likely difference between these two time/performance wise?
I'll look into all of that. Thanks for the useful info
In the WMP Changed State event I think I can use various checks like:
VB Code:
If mPlayer.playState = WMPLib.WMPPlayState.wmppsBuffering Then
End If
and perhaps update the countdown accordingly. This buffering may be equivalent in some respects to the pre-loading you were referring to.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|