收藏 分销(赏)

SilverLight播放音乐、视频.doc

上传人:pc****0 文档编号:7827154 上传时间:2025-01-19 格式:DOC 页数:4 大小:17.46KB 下载积分:10 金币
下载 相关 举报
SilverLight播放音乐、视频.doc_第1页
第1页 / 共4页
SilverLight播放音乐、视频.doc_第2页
第2页 / 共4页


点击查看更多>>
资源描述
播放音乐 添加进入声音时,要将音频时间置零。 音频格式最好是MP3格式的。 页面代码: <UserControl x:Class="MusicAndMovie.MainPage" xmlns=" xmlns:x=" xmlns:d=" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="500"> <Canvas x:Name="CanvasOne" Width="500" Height="400"> <MediaElement x:Name="MusicOne" Source="Sound/Start.mp3" AutoPlay="True" ></MediaElement> <MediaElement x:Name="MusicTwo" Source="Sound/click.mp3" AutoPlay="False"></MediaElement> <Button Name="btnGuess" Width="105" Height="40" Canvas.Left="324" Canvas.Top="291" Content="You Can Try Me!" MouseEnter="btnGuess_MouseEnter" MouseLeave="btnGuess_MouseLeave"></Button> </Canvas> </UserControl> 后台代码: using System; using System.Windows.Controls; using System.Windows.Input; namespace MusicAndMovie { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void btnGuess_MouseEnter(object sender, MouseEventArgs e) { TimeSpan time=new TimeSpan (); MusicTwo.Position = time; MusicTwo.Play(); btnGuess.Content = "You Can Try Me !"; } private void btnGuess_MouseLeave(object sender, MouseEventArgs e) { TimeSpan time = new TimeSpan(); MusicOne.Position = time; MusicOne.Play(); btnGuess.Content = "Baybay!"; } } } 播放视频 注意:设置资源后,将Web重新生成一下。AutoPlay应置为False 页面代码: <UserControl x:Class="Float.MainPage" xmlns=" xmlns:x=" xmlns:d=" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="White"> <MediaElement Source="TEB4ES_P01_C06_L01.wmv" AutoPlay="False" Width="800" Height="600" Name="mv01" ></MediaElement> <Button Name="btnStart" Width="50" Height="30" Margin="338,258,12,12" Click="btnStart_Click" MouseEnter="btnStart_MouseEnter" MouseLeave="btnStart_MouseLeave" Content="播放"></Button> </Grid> <UserControl.Resources> <Storyboard x:Name="storyOne"> </Storyboard> </UserControl.Resources> </UserControl> 后台代码: using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace Float { public partial class MainPage : UserControl { bool isplay = true; public MainPage() { InitializeComponent(); } private void btnStart_Click(object sender, RoutedEventArgs e) { if (isplay) { btnStart.Content = "暂停"; mv01.Play(); isplay = false; } else { btnStart.Content = "播放"; mv01.Pause(); isplay = true; } } private void btnStart_MouseEnter(object sender, MouseEventArgs e) { //添加鼠标进入效果、函数 } private void btnStart_MouseLeave(object sender, MouseEventArgs e) { } } }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 百科休闲 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服