Results 1 to 5 of 5

Thread: [2005] Any likely difference between these two time/performance wise?

  1. #1

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    [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:
    1. Private Sub MediaPlayer_StateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) _
    2.     Handles mPlayer.PlayStateChange
    3.  
    4.         If mPlayer.playState = WMPLib.WMPPlayState.wmppsPlaying Then
    5.             'Begin eye tracking here???
    6.  
    7.         End If
    8.  
    9.     End Sub

    Or:

    VB Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.  
    3.         intCount -= 1
    4.  
    5.         If Not intCount = 0 Then
    6.             Me.lblCount.Text = "Showing in: " & intCount.ToString
    7.         Else
    8.             Timer1.Enabled = False
    9.             Me.lblCount.Visible = False
    10.             'Show video:
    11.             mPlayer.URL = Application.StartupPath & "\Cases\JEPIFWEJ_LKL003.avi"
    12.             'Or begin eye tracking here ???
    13.  
    14.         End If
    15.  
    16.     End Sub
    Last edited by stimbo; Jan 24th, 2007 at 09:49 AM.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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

  3. #3

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    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,
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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

  5. #5

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    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:
    1. If mPlayer.playState = WMPLib.WMPPlayState.wmppsBuffering Then
    2.  
    3.  End If

    and perhaps update the countdown accordingly. This buffering may be equivalent in some respects to the pre-loading you were referring to.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width