Results 1 to 4 of 4

Thread: playing swf thru VB

  1. #1

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    playing swf thru VB

    I have a problem with my code, at least I think the problem in my code, and I am having a hard time explaining it. I click on a file in my drop down box, in this case an file with the .flv exstention or flash video. The code uses the swf component which loads an swf which in turn plays the flv. The first time always plays correctly.

    If I want to play another video and I click on my drop down box and choose the video, the new video loads and starts to play. However, if I do this while the first video is still playing I end up seeing the new video but hearing both audios from each video, It's like the first video isn't getting unloaded.

    I am totally perplexed and I want to rule out that my VB code is the cause and not my swf. Can someone help?

    Here is my code,
    VB Code:
    1. Option Explicit
    2.  
    3.  
    4. Private Function CreateDOM()
    5.     Dim dom
    6.     Set dom = New DOMDocument30
    7.     dom.async = False
    8.     dom.validateOnParse = False
    9.     dom.resolveExternals = False
    10.     dom.preserveWhiteSpace = True
    11.     Set CreateDOM = dom
    12. End Function
    13.  
    14. 'Private Sub Command1_Click()
    15. ' ShockwaveFlash1.Movie = App.Path & "\XML_FLV_player.swf"
    16. 'End Sub
    17.  
    18. Private Sub File1_Click()
    19.  
    20.     Dim dom, node, frag, cd, attr
    21.     Dim sReplaceChar As String
    22.     sReplaceChar = ""
    23.            
    24.     'On Error GoTo ErrorHandler
    25.     Set dom = CreateDOM
    26.    
    27.     ' Create a processing instruction targeted for xml.
    28.     Set node = dom.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
    29.     dom.appendChild node
    30.     Set node = Nothing
    31.    
    32.     ' Create a comment for the document.
    33.     Set node = dom.createComment("sample xml file created using XML DOM object.")
    34.     dom.appendChild node
    35.     Set node = Nothing
    36.    
    37.     ' Create the root element.
    38.     Dim root
    39.     Set root = dom.createElement("videos")
    40.    
    41.     ' Add the root element to the DOM instance.
    42.     dom.appendChild root
    43.     ' Insert a newline + tab.
    44.     root.appendChild dom.createTextNode(vbNewLine + vbTab)
    45.     ' Create and add more nodes to the root element just created.
    46.     ' Create a text element.
    47.     Set node = dom.createElement("video")
    48.    
    49.     'find and replace \ with / for flash
    50.      sReplaceChar = (File1.Path & "\" & File1.FileName)
    51.      sReplaceChar = Replace(sReplaceChar, "\", "/")
    52.     'node.Text = "some character data"
    53.     'node.Text = File1.Path & "/" & File1.FileName
    54.     node.Text = sReplaceChar
    55.     'MsgBox (node.Text)
    56.    
    57.     ' Add text node to the root element.
    58.     root.appendChild node
    59.     Set node = Nothing
    60.       ' Add a newline plus tab.
    61.     root.appendChild dom.createTextNode(vbNewLine + vbTab)
    62.    
    63.     ' Save the XML document to a file.
    64.     dom.save App.Path + "\flv.xml"
    65.     Set root = Nothing
    66.     Set dom = Nothing
    67.    
    68. '    Unload frmhome
    69. '    Load frmhome
    70. '    frmhome.Show
    71.    
    72.        'AxShockwaveFlash1.LoadMovie(1, Application.StartupPath & "\XML_FLV_player.swf")
    73.         'AxShockwaveFlash1.Movie = Application.StartupPath & "\XML_FLV_player.swf"
    74.         'Me.AxShockwaveFlash1.GotoFrame (1)
    75.         'Me.AxShockwaveFlash1.StopPlay()
    76.        
    77.    
    78.     Call ShockwaveFlash1.LoadMovie(1, App.Path & "\XML_FLV_player.swf")
    79.     ShockwaveFlash1.Movie = App.Path & "\XML_FLV_player.swf"
    80.     Me.ShockwaveFlash1.GotoFrame (1)
    81.     Me.ShockwaveFlash1.StopPlay
    82.    
    83.     frmhome.txtInfo.Text = ""
    84.    
    85.     'frmshockwave.Caption = frmhome.File1.FileName
    86.     'load shockwave form
    87.     'Unload frmshockwave
    88.    ' Load frmshockwave
    89.     'frmshockwave.Show
    90.  
    91.     Exit Sub
    92.    
    93. ErrorHandler:
    94.     MsgBox Err.Description
    95. End Sub
    96.  
    97. 'search for flv file
    98. Private Sub Drive1_Change()
    99.     Dir1.Path = Drive1.Drive
    100. End Sub
    101.  
    102. Private Sub Dir1_Change()
    103.     File1.Path = Dir1.Path
    104.     File1.Pattern = "*.flv"
    105. End Sub
    106.  
    107.  
    108. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    109.     If UnloadMode = 0 Then
    110.             Dim Msg   ' Declare variable.
    111.             'Set the message text.
    112.             Msg = "Do you really want to exit?"
    113.             'If user clicks the No button, stop QueryUnload.
    114.             If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbYes Then
    115.                 Call closeAllForms
    116.                 'Unload frmIntro
    117.                 Cancel = False
    118.             Else
    119.                 Cancel = True
    120.             End If
    121.         End If
    122.        
    123. End Sub
    124.  
    125. Private Sub ShockwaveFlash1_FSCommand(ByVal command As String, ByVal args As String)
    126.  
    127.     If (command = "info") Then
    128.         'frmhome.txtInfo.Text = (args)
    129.         frmhome.txtInfo.Text = frmhome.txtInfo.Text & args & vbNewLine
    130.     Else
    131.        MsgBox (args)
    132.     End If
    133.    
    134. '    If (command = "video") Then
    135. '        frmhome.txtInfo.Text = frmhome.txtInfo.Text & args & vbNewLine
    136. '    Else
    137. '        MsgBox (args)
    138. '    End If
    139. '
    140.    
    141. End Sub
    He who never made a mistake never made a discovery?

  2. #2
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 2003
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: playing swf thru VB

    Since no responses thus far, I guess I will take a stab at it. My guess is your flash players buffer needs to be cleared or reset. I dont see a closing or stopping of the active movie before you start a new one, your simply loading the new one.

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: playing swf thru VB

    But where's the Drop down box's code?? Try
    VB Code:
    1. Me.ShockwaveFlash1.StopPlay
    at the beginning of the DropDown box's code.
    Show Appreciation. Rate Posts.

  4. #4

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: playing swf thru VB

    Ok strictly speaking I have a Drive, DIR and File boxes. I tried the Me.Shockwave1/StopPlay, and it did not work.

    So how do I close the active movie befor starting a new one?
    He who never made a mistake never made a discovery?

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