夏天PLUS 2015-07-17 03:47 采纳率: 16.7%
浏览 1552

vs2012sliverlight 播放音频文件

我用vs2012sliverlight 播放wma文件,按照silverlight从入门到精通 关于媒体播放mediaelement的使用,步骤一样,可是浏览器无法播放,运行时没有提示出错???
声音文件已经添加到工程目录,MediaElement设置为“永远图片说明复制”,“RESOURCE”
图片说明

``` xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">

    <StackPanel Orientation="Vertical">
        <MediaElement  x:Name="mediaplay" HorizontalAlignment="Left" 
                       Height="100" VerticalAlignment="Top" Width="100" Source="ALARM.WAV"/>
        <StackPanel Orientation="Horizontal">
            <Button x:Name="play" Content="播放" Height="100" Width="100" Click="play_Click"/>
        </StackPanel>
    </StackPanel>
</Grid>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace AlarmVoice
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}

    private void play_Click(object sender, RoutedEventArgs e)
    {
        mediaplay.Play();
    }
}

}




  • 写回答

3条回答

  • 91program 博客专家认证 2015-07-17 03:52
    关注

    建议你先试试 Media Player 能不能播放这个 WMA 文件。

    评论

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入