none
Audio synching in Silvelight 1.0 Javascript

    Question

  • Hi,  I’m working on a project where I’m recreating a flash created animation into Silverlight 1.0. Within my Flash file I’ve an animation which is synched with the audio. Now in Expression blend when I insert Audio file (.MP3) it shows me the audio file inside the storyboard but when I play the storyboard within Blend itself i.e. without Testing the Solution (Pressing F5 key) then it does not play the audio. To listen to the audio I’ve to test the solution. This is making it difficult to synch the animation with the audio file. Please help me in suggesting the best approach to synch an animation with audio in blend/Silverlight.  Thanks in advance

     

    Friday, November 02, 2007 7:09 AM

Answers

  • Ok. Heres how to do that. Say you wanted your audio to start at 8 seconds. Then you will create a new timeline that doesnt change anything, but lasts exactly 8 seconds. Set up a completed event for that timeline to start the audio. <.."Timeline2"... Completed="AudioStart"...>

    Then in your javascript you would:

    function AudioStart(sender, eventArgs){

    sender.findName("YourAudioFile").Play();

    }

    Also, on your MediaElement, make sure you set the AutoPlay="False"

    This is probably the easiest way of doing it. Let me know if you need further assistance.

    Monday, November 05, 2007 9:11 AM

All replies

  • I cant get you in proper, anyway to play audio file, that .mp3 in blend just you can do that with adding them in Mediaelement

    <MediaElement x:Name="Sound1_mp3" Width="0" Height="0" Canvas.Left="409" Canvas.Top="216" Source="Sound1.mp3" Stretch="Fill"/>

    Rgrds,

    Laksha

    Friday, November 02, 2007 7:15 AM
  • Hi Laksha,

    thanks for the prompt reply. I've added the  audio file in exactly the same way as you have written. My requirement is i want to listen to the audio and then adjust the animation key frames so that the animation is in synch with the audio. In short i want to hear the audio in authoring environment and modify the animation.

    But I'm able to hear the audio file only when i test the solution. i.e. Only during run time.

    Is there any solution to that?

    Thanks

     

    Friday, November 02, 2007 7:22 AM
  • It sounds like you're trying to create a timeline and have the audio match up with that. You just need to figure out when your audio needs to start, at which time, then start it at that point. There isn't a way to preview audio using Blend2 if thats your question. You would need to build the solution in order to do this. If you need help with delaying the start of the audio let me know.

    Friday, November 02, 2007 8:59 AM
  • Can't you just copy the animation based on the timeline in Flash? Because in the flash-timeline the audio is already synced right? You could get the timings from the Flash timeline, and put those into the Silverlight timeline.

    It isn't possible in Expression Blend to prelisten the audio. If you really need to you could try to start the audio in a seperate media player(winamp/wmp) and start the timeline in Blend at the same time.  

    Friday, November 02, 2007 12:09 PM
  • Hi

    Nick, can you please let me know what i'll have to do if i've to delay the start of the audio?

    thanks in advance

    Monday, November 05, 2007 1:50 AM
  •  Put some empty frames in front of the start of the animation.

    Monday, November 05, 2007 3:37 AM
  • Ok. Heres how to do that. Say you wanted your audio to start at 8 seconds. Then you will create a new timeline that doesnt change anything, but lasts exactly 8 seconds. Set up a completed event for that timeline to start the audio. <.."Timeline2"... Completed="AudioStart"...>

    Then in your javascript you would:

    function AudioStart(sender, eventArgs){

    sender.findName("YourAudioFile").Play();

    }

    Also, on your MediaElement, make sure you set the AutoPlay="False"

    This is probably the easiest way of doing it. Let me know if you need further assistance.

    Monday, November 05, 2007 9:11 AM
  • You can try specifying the audio times (sender.findName("media").Position.Seconds) in an XML file and play/pause your animation based on these times.

    It works the best and is also localisation-friendly.

    Saturday, March 07, 2009 3:26 AM
  •  can som1 post sample code? please...

    Wednesday, April 22, 2009 8:19 AM