471,107 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,107 software developers and data experts.

Trouble with DirectX.AudioVideoPlayback.Audio

If I have an audio file playing using DirectX.AudioVideoPlayback.Audio and I
click the stop button, using the following code:

Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStop.Click
End Try
End Sub

Private Sub PlayerStopped(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Player.Stopping
While Player.Stopped = False
'do nothing here. we're waiting for it to stop.
End While
Player = Nothing
Catch ex As Exception
End Try
trkPosition.Value = 0
lblPosition.Text = "0:00"
MsgBox("Made it thru this sub")
End Sub

I get the following exception:

System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an
indication that other memory is corrupt."
at AudioWndProc(HWND__* hWnd, UInt32 uMsg, UInt32 wParam, Int32
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
at eDeeJay.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Line 81 referred to in the StackTrace happens to be the "Handles
Player.Stopping" line.

I was using:

Player = Nothing
Catch ex As Exception
End Try

in the btnPlay_Click event to unload the player and reload and it worked
fine. But I need to unload the player when I click the Stop button. If I
move the Try block back up so it is in the Play button event code, it works
fine again. The MsgBox in the Player.Stopping event fires so I know it's
making it all the way through the code there. But as soon as I click the OK
button in the MsgBox, I get the error above. What gives?
Jan 15 '07 #1
0 1921

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kieran Benton | last post: by
2 posts views Thread by Michael Mayer | last post: by
reply views Thread by Jovo Mirkovic | last post: by
11 posts views Thread by raylopez99 | last post: by

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.