locked
Problem with play two music RRS feed

  • Question

  • I've got a problem that I couldn't play more than 1 music (by Sound.Play). If I do it I've got an error:

       w System.Windows.Threading.DispatcherObject.VerifyAccess()
       w System.Windows.Freezable.WritePreamble()
       w System.Windows.Media.MediaPlayer.Stop()
       w Microsoft.SmallBasic.Library.Sound.Stop(Primitive filePath)
       w _SmallBasicProgram.prolog()
       w _SmallBasicProgram.klik1()
       w Microsoft.SmallBasic.Library.Controls.OnButtonClicked(Object sender, RoutedEventArgs e)
       w System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       w System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       w System.Windows.Controls.Button.OnClick()
       w System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       w System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       w System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       w System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       w System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
       w System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       w System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       w System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       w System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       w System.Windows.Input.InputManager.ProcessStagingArea()
       w System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       w System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       w System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       w System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       w System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       w MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       w MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       w System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       w System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       w System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       w MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       w MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       w System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
       w System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       w System.Windows.Application.RunInternal(Window window)
       w Microsoft.SmallBasic.Library.Internal.SmallBasicApplication.<>c__DisplayClass1.<.cctor>b__0()
       w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       w System.Threading.ThreadHelper.ThreadStart()

    My small basic code which doesn't work is very simple:

    Sound.Stop("1st music")
    Delay(20)
    Sound.Play("2nd music")
    What should I do to start it work well? I heard about Data Extension but I couldn't find website where I can download it.
    Tuesday, December 16, 2014 6:20 PM

Answers

  • We would need to see the code to be sure.

    You seem to already be doing a Play.Stop before Play.Start, which is the usual problem with repeated plays.

    From the error log it looks like you are doing the Sound stuff inside an event subroutine - event subroutines work on separate threads and can cause problems.  Try doing the sound bits on the main UI thread.

    See here for some more details.

    Thursday, November 5, 2015 11:27 AM

All replies

  • This is a little odd that this December post is showing up now. Anyway, Plew, are you still curious?

    Thanks!


    Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Thursday, November 5, 2015 3:53 AM
  • We would need to see the code to be sure.

    You seem to already be doing a Play.Stop before Play.Start, which is the usual problem with repeated plays.

    From the error log it looks like you are doing the Sound stuff inside an event subroutine - event subroutines work on separate threads and can cause problems.  Try doing the sound bits on the main UI thread.

    See here for some more details.

    Thursday, November 5, 2015 11:27 AM