wpf中MediaPlayer的属性含钙高的食物有哪些些

wpf 中 用 media player 播放没有声音 代码是按书上敲的 没问题 但就是没声音_百度知道
wpf 中 用 media player 播放没有声音 代码是按书上敲的 没问题 但就是没声音
提问者采纳
你设置一下Volume这个属性值,他的值范围是0到1
你把代码粘出来看看吧
private MediaPlayer player = new MediaPlayer();
private void button1_Click(object sender, RoutedEventArgs e)
player.Open(new Uri(@&Sound\Man\1.wav&, UriKind.Relative));
player.Volume = 1;
player.Play();
你这个MediaPlayer 是什么呀,不是WPF自带的MediaElement呀?
private void button1_Click(object sender, RoutedEventArgs e)
mediaElement1.Position = TimeSpan.Z
mediaElement1.LoadedBehavior = MediaState.M
mediaElement1.Volume = 1;
mediaElement1.Play();
mediaElement1.Position = TimeSpan.Z这个不用设置!
public MainWindow()
InitializeComponent();
mediaElement1.Source = new Uri(@&Sound\Man\1.wav&, UriKind.Relative);
}这样加载应该行吧?
你就直接在前台弄吧!就加一个Source属性就可以了!
前台也不行,还是没声音,而且 我测了一下加载的进度,
确实加载了,但还是不出声音,有说是
版本的问题, 我的版本是
visual studio 2010
.net framework 4.0
windows media
player 组件是 1.0
这个就不太清楚了
提问者评价
其他类似问题
wpf的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁当前位置:&&
本页文章导读:
&&&&?解析WPF实现音频文件循环顺序播放的解决方法&&&&&&
要做基于WPF的音频文件循环顺序播放首先要了解WPF下有哪些类是用于控制音频的. WPF下主要有两个音频控制的类,这里做下比较:    1.SoundPlayer      2.MediaPlayer     派生M......&&&&?解析WPF绑定层次结构数据的应用详解&&&&&&
在实际项目应用中会存在多种类型的层次结构数据,WPF提供了良好的数据绑定机制。其中运用最频繁的就是ListBox和TreeView控件。一、ListBox和TreeView控件的区别1.ListBox显示单层次数据集合,Tree......&&&&?基于.NET BitmapImage 内存释放问题的解决方法详解&&&&&&
网上查到的代码,多数的写法使用MemoryStream来实现: 代码如下:new Thread(new ThreadStart(() =& {
var bitmap = new BitmapImage();
bitmap.BeginInit();
using (var stream = new MemoryStream(File.ReadAllBytes(........
&&&&&&最新IT科技资讯推荐:
[1]解析WPF实现音频文件循环顺序播放的解决方法
&&&&来源:&互联网& 发布时间:&
要做基于WPF的音频文件循环顺序播放首先要了解WPF下有哪些类是用于控制音频的. WPF下主要有两个音频控制的类,这里做下比较:    1.SoundPlayer      2.MediaPlayer     派生MediaElement一.SoundPlayer类
    1.基于.NET FRAMEWORK 2.0;    2.可播放WAV音频文件;     3.只能播放一个文件,同时播放多个文件会后一个文件的播放操作会终止前一个播放的文件;    4.不能对音量进行控制;二.MediaPlayer类    1.基于WPF;     2.支持多种音频文件;    3.可以同时播放多个声音;    4.可以调整音量对音频进行控制;    5.支持设置静音和左右扬声器;    6.可以控制音频播放速度和获取播放进度和控制进度;     
MediaElement类同MediaPlayer的功能类似,作为WPF页面可用的标签是MediaPlayer的衍生; WPF下音频文件循环顺序播放的开发思路:首先新建一个类继承MediaElement;这个类包含播放逻辑功能:    1.读取指定文件夹内的所有音频文件;    2.将读取的文件路径放入列表;    3.顺序读取列表中的文件名;    4.播放音频文件;    5.播放完毕读取下一个文件名直至列表结尾;    6.播放音频文件至列表结尾则转制列表头继续播放;在XAML界面加载这个类;Window Load事件里执行这个类的播放列表;下面贴出了WPF下音频文件循环顺序播放的代码: 代码如下:WPF界面代码
&Window x:
xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:md="clr-namespace:MediaApplication"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"&
&StackPanel&
&md:MediaManager x:Name="media"&&/md:MediaManager&
&/StackPanel&
&/Window& 代码如下:WPF界面CS代码
using S using System.Collections.G using System.L using System.T using System.W using System.Windows.C using System.Windows.D using System.Windows.D using System.Windows.I using System.Windows.M using System.Windows.Media.I using System.Windows.N using System.IO; using System.Collections.ObjectM using System.C namespace MediaApplication {
/// &summary&
/// Interaction logic for MainWindow.xaml
/// &/summary&
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
private void Window_Loaded(object sender, RoutedEventArgs e) {
this.media.PlayList();
} } 代码如下:MediaManager类 using Susing System.Collections.Gusing System.Lusing System.Tusing System.Windows.Cusing System.IO;using System.Cusing System.Wusing System.Collections.ObjectMnamespace MediaApplication {
public class MediaManager : MediaElement {
public MediaManager() {
GetAllDirList(new DirectoryInfo(ConfigurationManager.AppSettings["dir"].ToString()));
public void PlayList() {
if(files.Count & 0)
this.UnloadedBehavior = MediaState.M
this.LoadedBehavior = MediaState.M
this.MediaEnded += new RoutedEventHandler(media_MediaEnded);
this.Source = new Uri( files[index], UriKind.RelativeOrAbsolute);
this.Play();
private void GetAllDirList(DirectoryInfo directory) {
foreach(string filter in filters)
foreach (FileInfo file in directory.GetFiles(filter)) {
files.Add(file.FullName);
foreach (DirectoryInfo subDirectory in directory.GetDirectories()) {
GetAllDirList(subDirectory);
private void media_MediaEnded(object sender, RoutedEventArgs e) {
this.Source = new Uri( files[++index % files.Count], UriKind.RelativeOrAbsolute);
this.Play();
private ObservableCollection&string& files = new ObservableCollection&string&();
private int index = 0;
private string[] filters = new string[] { "*.wav", "*.mp3" };
[2]解析WPF绑定层次结构数据的应用详解
&&&&来源:&互联网& 发布时间:&
在实际项目应用中会存在多种类型的层次结构数据,WPF提供了良好的数据绑定机制。其中运用最频繁的就是ListBox和TreeView控件。一、ListBox和TreeView控件的区别1.ListBox显示单层次数据集合,TreeView可以显示单层次和多层次数据集合;2.通过ListBox在UI层面可以展示良好的数据显示效果,对数据集合可以进行排序、分组、过滤操作;3.TreeView显示为一个多层次的数据集合为树形结构,通过Templete和Style属性同样可以为其定义良好的数据显示效果;二、ListBox控件示例1.ListBox绑定数据进行分组:使用ListBox.GridStyle标签,定义HeaderTemplate属性用来定义组头的外观: 代码如下:代码
&ListBox ItemSource="{Binding Path=Data}"&
&ListBox.GridStyle&
&GroupStyle.HeaderTemplate&
&DataTemplate&
&Stackpanel&
&Image Source="xxx.jpg"/&
&Label Content="C:"/&
&Stackpanel&
&/DataTemplate&
&/GroupStyle.HeaderTemplate&
&/ListBox.GridStyle& ......
&/ListBox&这样就可以创建出类似WINDOWS 文件管理器的效果:
2.Listbox一些使用经验:/1 如果要实现类似WINDOWS的漂亮的界面效果并进行分组,需要自定义GroupStyle的样式,否则WPF会使用内建的GroupStyle,也可以引用GroupStyle.Default静态属性。/2 ListBox只能定义一层数据结构,在ListBox中的Item里再次使用ListBox,后ListBox里的ItemSource不会继承上一层ListBox的Item源中的数据集合,如有如下数据集合: 代码如下:public List&Groups& groups = new List&Groups&();groups.Add(new Group);........ 代码如下:public class Group {
public int Id { }
public string Name { }
private List&Box& boxes = new List&Box&();
public List&Box& Boxes {
}Listbox的ItemSource Binding List&Groups&的数据集合,其Item中的ListBox Binding List&Box&,则Item中的ListBox是无法获取List&Box&这个数据集合的;三、TreeView控件示例1.有如上数据集合,使用TreeView绑定多层数据集合: 代码如下:代码
&TreeView x:Name="maintree" FocusVisual ItemsSource="{Binding Groups}"&
&TreeView.ItemContainerStyle&
&Style TargetType="{x:Type TreeViewItem}"&
&Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /&
&Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /&
&Setter Property="FontWeight" Value="Normal" /&
&Style.Triggers&
&Trigger Property="IsSelected" Value="True"&
&Setter Property="FontWeight" Value="Bold"/&
&/Trigger&
&/Style.Triggers&
&/TreeView.ItemContainerStyle&
&TreeView.Resources&
&HierarchicalDataTemplate DataType="{x:Type m:GroupVO}" ItemsSource="{Binding Boxes}"&
&StackPanel Orientation="Horizontal"&
&Label Content="{Binding Path=FriendlyName}"&&/Label&
&CheckBox VerticalAlignment="Center" IsChecked="{Binding Path=IsSelected}"&&/CheckBox&
&/StackPanel&
&/HierarchicalDataTemplate&
&DataTemplate DataType="{x:Type m:BoxVO}"&
&Grid Margin="0,5,5,10" MouseDown="maintree_MouseDown" Loaded="Grid_Loaded"&
&Grid.RowDefinitions&
&RowDefinition&&/RowDefinition&
&/Grid.RowDefinitions&
&Grid.ColumnDefinitions&
&ColumnDefinition Width="*"&&/ColumnDefinition&
&ColumnDefinition Width="6*"&&/ColumnDefinition&
&/Grid.ColumnDefinitions&
&Image Source="/Resources/Images/shgbit.png" Width="50" VerticalAlignment="Top" Grid.Column="0" Grid.Row="0"&&/Image&
&Label Grid.RowSpan="2" Grid.Row="0" Grid.Column="0" Margin="5,5,0,0" Content="{Binding Path=FriendlyName}"&&/Label&
&/DataTemplate&
&/TreeView.Resources&
&/TreeView&HierarchicalDataTemplate属性为层级数据模板,它继承数据集合的层级结构,要表示树的层级依赖关系必须使用HierarchicalDataTemplate。属性绑定数据使用TwoWay是为双向属性,当源数据或目标被改变是更新另一方的数据。在层次树表示中的典型应用就是:用CheckBox进行子节点的选中和未选中的状态传递。
[3]基于.NET BitmapImage 内存释放问题的解决方法详解
&&&&来源:&互联网& 发布时间:&
网上查到的代码,多数的写法使用MemoryStream来实现: 代码如下:new Thread(new ThreadStart(() =& {
var bitmap = new BitmapImage();
bitmap.BeginInit();
using (var stream = new MemoryStream(File.ReadAllBytes(...))) {
bitmap.StreamSource =
bitmap.CacheOption = BitmapCacheOption.OnL
bitmap.EndInit();
bitmap.Freeze();
this.Dispatcher.Invoke((Action)delegate {
Image1.Source =
})).Start();今天问题来了,当我设置了DecodeWidth为100时加载1000张图片,照理说内存应该维持100×100的1000张图片,但事实上他保留了所以原始图片的内存直到BitmapImage被回收时才释放,这让我很尴尬,换句话说using(MemoryStream)并没有真正按我们预期释放MemoryStream中的Buffer,那如何才能释放呢?其实最简单就是直接弃用MemoryStream转投FileStream,如下: 代码如下:using (var stream = new FileStream(path, FileMode.Open)) {
image.BeginInit();
image.StreamSource =
image.DecodePixelWidth = 100;
image.CacheOption = BitmapCacheOption.OnL
image.EndInit();
image.Freeze();}
最新技术文章:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!
(C)2012-,站长邮箱:www_169it_(请将#改为@)WPF中如何写RTSP/RTP播放器,200分求思路,标题要长========
[问题点数:200分,结帖人nonocast]
WPF中如何写RTSP/RTP播放器,200分求思路,标题要长========
[问题点数:200分,结帖人nonocast]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2013年8月 .NET技术大版内专家分月排行榜第三2011年10月 .NET技术大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。}

我要回帖

更多关于 dnf幻影手镯属性 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信