locked
MediaElement RRS feed

  • 问题

  • I want to use MediaElement control to play a mp3 file.,but failed:Nothing happens

    The code is :

    <MediaElement Source="/SilverlightApplication12;component/1.mp3" AutoPlay="True" />

    Can anyone give me some advice?Thanks a lot!

    2011年9月23日 5:23

答案

  • Hi,

    You can't set Source property of MediaElement like this: Source="/SilverlightApplication12;component/1.mp3".

    Please follow steps below:

    1. Open your project in Visual studio.

    2. Right click your media(1.mp3)->Properties, Set the Build Action value to Resource on Properties Window

    3. Set Srouce Source property of MediaElement like this:

            <MediaElement x:Name="MediaPalyer" Source="1.mp3" />

     

    For more information of Resource file, plese check link below:

    http://msdn.microsoft.com/en-us/library/cc296240(v=VS.95).aspx

     

    Hope this helps you.


    Daoping Liu - MSFT
    2011年9月26日 7:04

全部回复

  • 你确定你的项目bin文件夹里面有这个mp3文件没
    My Blog<
    2011年9月26日 3:23
  • Hi,

    You can't set Source property of MediaElement like this: Source="/SilverlightApplication12;component/1.mp3".

    Please follow steps below:

    1. Open your project in Visual studio.

    2. Right click your media(1.mp3)->Properties, Set the Build Action value to Resource on Properties Window

    3. Set Srouce Source property of MediaElement like this:

            <MediaElement x:Name="MediaPalyer" Source="1.mp3" />

     

    For more information of Resource file, plese check link below:

    http://msdn.microsoft.com/en-us/library/cc296240(v=VS.95).aspx

     

    Hope this helps you.


    Daoping Liu - MSFT
    2011年9月26日 7:04
  • thanks for your help
    2012年9月4日 5:50