Help with PlaySoundBehavior in Blend 3 RRS feed

  • Question

  • I've been playing with the new Behaviors in Blend 3 and have been able to get all of them to work, except for the one that I thought would be the most straight forward: PlaySoundAction.

    Is anyone else having any trouble with this one? Can someone maybe shed some light on what I'm missing?

    I have an elipse on the stage that i'm adding the behavior to and i'm setting the EventName to "MouseEnter", in hopes that when i build the project and hover over the ellipse, it will play a sound. I tried it w/ both a wav and an mp3. Any suggestions?


    Friday, July 17, 2009 5:56 PM


All replies

  • Can you please help a little more with the repro steps?

    Here is what I tried:
    a) Create a new Silverlight 3 Application
    b) Add Foo.wma to the project
    c) Draw a Rectangle
    d) Drag and drop the PlaySoundAction on the Rectangle
    e) Choose Foo.wma as a source

    Test the application - click on the Rectangle - the sound plays.

    Is this what you tried as well?

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 17, 2009 7:53 PM
  • Make sure that the PlaySoundAction is listening to the right element for the MouseEnter event.  This can be accomplished by either applying the Behavior directly to the Elipse or set the SourceName of the EventTrigger to the Ellipse. 
    Friday, July 17, 2009 8:28 PM
  • Yes, that is exactly what I have done, but there still is no sound. I have checked my speakers and they do play when listening to WMP etc. And I'm just using the chimes.wav from Windows.

    Here's the XAML:

     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
     Width="640" Height="480">

     <Grid x:Name="LayoutRoot" Background="White">
      <Rectangle x:Name="rectangle" Fill="Black" Stroke="Black" Margin="210,157,263,204">
        <i:EventTrigger EventName="MouseLeftButtonDown" SourceName="rectangle">
         <im:PlaySoundAction Volume="0.97" Source="/chimes.wav"/>

    Friday, July 17, 2009 9:14 PM
  • Thanks Scott,

    I have tried setting the SourceName as both Parent (the default) and also tried specifying elipse/rectangle, but it still does not work.

    Can you think of anything else, I should check? I posted the XAML above.


    Friday, July 17, 2009 9:17 PM
  • Can you please share out the project?

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 17, 2009 9:52 PM
  • here's the project


    thanks again!
    Friday, July 17, 2009 10:22 PM
  • Thanks. I think this is probably because you are using a WAV file.


    MP3 should be ok, however (I tried it out myself).

    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by MattW_MD Friday, July 17, 2009 11:04 PM
    Friday, July 17, 2009 10:59 PM
  • I tried it w/ a WMA and it works!

    I had read in the documentation that Blend supported WMA (and many others) but I failed to see the fine print saying that it was only for WPF and NOT Silverlight. :P

    Big thanks Unni! Now I can sleep tonight...
    Friday, July 17, 2009 11:07 PM