本文整理汇总了C#中System.Windows.Controls.MediaElement类的典型用法代码示例。如果您正苦于以下问题:C# MediaElement类的具体用法?C# MediaElement怎么用?C# MediaElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaElement类属于System.Windows.Controls命名空间,在下文中一共展示了MediaElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: App
/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard Silverlight initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
{
// Display the current frame rate counters.
Application.Current.Host.Settings.EnableFrameRateCounter = true;
// Show the areas of the app that are being redrawn in each frame.
//Application.Current.Host.Settings.EnableRedrawRegions = true;
// Enable non-production analysis visualization mode,
// which shows areas of a page that are handed off to GPU with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
// application's PhoneApplicationService object to Disabled.
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
// and consume battery power when the user is not using the phone.
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
// Find the AlarmSound resource and store it
alarmSound = (MediaElement)this.Resources["AlarmSound"];
}
示例2: OnApplyTemplate
public override void OnApplyTemplate()
{
if (this.mediaElement != null)
{
this.mediaElement.Loaded -= this.Media_Loaded;
this.mediaElement.MediaEnded -= this.MediaElement_MediaEnded;
}
if (this.playPauseButton != null)
{
this.playPauseButton.HoverClick -= this.PlayPauseButton_HoverClick;
}
base.OnApplyTemplate();
this.mediaElement = this.Template.FindName(Media, this) as MediaElement;
this.playPauseButton = this.Template.FindName(PlayPauseButton, this) as HoverDwellButton;
if (this.mediaElement != null)
{
this.mediaElement.Loaded += this.Media_Loaded;
this.mediaElement.MediaEnded += this.MediaElement_MediaEnded;
}
if (this.playPauseButton != null)
{
this.playPauseButton.HoverClick += this.PlayPauseButton_HoverClick;
}
}
示例3: Player
private Player()
{
_player = new MediaElement();
_player.LoadedBehavior = MediaState.Manual;
_player.UnloadedBehavior = MediaState.Manual;
_player.ScriptCommand += new EventHandler<MediaScriptCommandRoutedEventArgs>(RaiseSongChanged);
}
示例4: Courses
public Courses(SurfaceWindow1 parentWindow)
: base(parentWindow)
{
InitializeComponent();
DataContext = this;
accordian_fx = new MediaElement();
accordian_fx.LoadedBehavior = MediaState.Manual;
accordian_fx.UnloadedBehavior = MediaState.Manual;
accordian_fx.LoadedBehavior = MediaState.Manual;
accordian_fx.Volume = 1.0;
accordian_fx.IsMuted = false;
Cse_items.Add(new DataItem("Description", new Controls.FlowDocControl("Resources/docs/specialisations/cse_info.xaml")));
Cse_items.Add(new DataItem("Careers", new Controls.FlowDocControl("Resources/docs/specialisations/cse_careers.xaml")));
Cse_items.Add(new DataItem("Courses", new Controls.CoursesControl("cse")));
Cse_items.Add(new DataItem("Programme Advisor", new Controls.FlowDocControl("Resources/docs/specialisations/cse_advisor.xaml")));
Se_items.Add(new DataItem("Description", new Controls.FlowDocControl("Resources/docs/specialisations/se_info.xaml")));
Se_items.Add(new DataItem("Careers", new Controls.FlowDocControl("Resources/docs/specialisations/se_careers.xaml")));
Se_items.Add(new DataItem("Courses", new Controls.CoursesControl("se")));
Se_items.Add(new DataItem("Programme Advisor", new Controls.FlowDocControl("Resources/docs/specialisations/se_advisor.xaml")));
Eee_items.Add(new DataItem("Description", new Controls.FlowDocControl("Resources/docs/specialisations/eee_info.xaml")));
Eee_items.Add(new DataItem("Careers", new Controls.FlowDocControl("Resources/docs/specialisations/eee_careers.xaml")));
Eee_items.Add(new DataItem("Courses", new Controls.CoursesControl("eee")));
Eee_items.Add(new DataItem("Programme Advisor", new Controls.FlowDocControl("Resources/docs/specialisations/eee_advisor.xaml")));
setControl(new Controls.FlowDocControl("Resources/docs/tap_course.xaml"));
}
示例5: ServiceItem
public ServiceItem()
{
VideoPlayer = new MediaElement();
AudioPlayer = new MediaPlayer();
//string loopFilter = "";
//// specific filters to prevent announcement loops from being included in song loops
//loopFilter = "background*.mp*";
//FileInfo[] padsDi = new DirectoryInfo(Properties.Resources.PadPath).GetFiles("*.mp3");
//FileInfo[] loopsDi = new DirectoryInfo(Properties.Resources.LoopPath).GetFiles(loopFilter);
//Pads = new List<string>();
//Pads.Add("");
//foreach (FileInfo pad in padsDi)
// Pads.Add(System.IO.Path.GetFileNameWithoutExtension(pad.Name));
//Loops = new List<string>();
//Loops.Add("");
//foreach (FileInfo loop in loopsDi)
// Loops.Add(System.IO.Path.GetFileNameWithoutExtension(loop.Name.Remove(0, loopFilter.Length - 4)));
}
示例6: init
public void init(List<MediaElement> mediaElements)
{
intro = mediaElements[0];
death = mediaElements[1];
eat_ghost = mediaElements[2];
extra_life = mediaElements[3];
eat_dot = mediaElements[4];
eat_fruit = mediaElements[5];
background = mediaElements[6];
alarm = mediaElements[7];
power = mediaElements[8];
intro.MediaEnded += new RoutedEventHandler(Intro_Ended);
death.MediaEnded += new RoutedEventHandler(Death_Ended);
alarm.MediaEnded += new RoutedEventHandler(Alarm_Ended);
background.MediaEnded += new RoutedEventHandler(Background_Ended);
eat_dot.MediaEnded += new RoutedEventHandler(EatDot_Ended);
power.MediaEnded += new RoutedEventHandler(Power_Ended);
isAlarmPlaying = false;
isBackgroundPlaying = false;
isEatDotPlaying = false;
isPowerPlaying = false;
/* intro.Source = new Uri(@"..\..\Sounds\pacman_song1.wav", UriKind.Relative);
death.Source = new Uri(@"..\..\Sounds\pacman_death.wav", UriKind.Relative);
eat_ghost.Source = new Uri(@"..\..\Sounds\pacman_getghost.wav", UriKind.Relative);
extra_life.Source = new Uri(@"..\..\Sounds\pacman_extralife.wav", UriKind.Relative);
eat_dot.Source = new Uri(@"..\..\Sounds\pacman_coinin.wav", UriKind.Relative);
eatfruit.Source = new Uri(@"..\..\Sounds\pacman_eatfruit.wav", UriKind.Relative);
background.Source = new Uri(@"..\..\Sounds\pacman_background1.wav", UriKind.Relative);
alarm.Source = new Uri(@"..\..\Sounds\pacman_alarm1.wav", UriKind.Relative);*/
}
示例7: VideoJigsawRectPiece
public VideoJigsawRectPiece(MediaElement mediaElement, int col, int row, double pieceSize)
: base(mediaElement, col, row, pieceSize)
{
this._origin = new Point((col * pieceSize), (double)(row * pieceSize));
this.Position = new Point((col * pieceSize), (double)(row * pieceSize));
base.InitShapeProperties();
}
示例8: VideoService
public VideoService(
Rectangle viewFinder,
MediaElement player
)
{
// Initial State
_State = PlayState.Paused;
_CanRecord = false;
_Record = new SwitchableCommand(OnRecord);
_Play = new SwitchableCommand(OnPlay);
_Stop = new SwitchableCommand(OnPause);
_ViewFinder = viewFinder;
_Player = player;
_Player.MediaEnded += MediaEnded;
_CaptureSource = new CaptureSource();
_CaptureSource.CaptureFailed += CaptureFailed;
_FileSink = new FileSink();
_Brush = new VideoBrush();
_HasRecording = new BehaviorSubject<bool>(false);
}
示例9: FullScreenPlayer
public FullScreenPlayer(Node current, Player ucPlayer, MediaElement parent, TimeSpan now)
{
InitializeComponent();
//if (!File.Exists(current.Filelocation))
//{
// MessageBox.Show("文件不存在!!");
//}
//else
//{
// VideoUtil.encode(current.Filelocation);
//}
this.parent = parent;
this.current = current;
this.ucPlayer = ucPlayer;
player.Width = SystemParameters.VirtualScreenWidth;
player.Height = SystemParameters.VirtualScreenHeight - 45;
//wpfMediaPlayer.URL = current.Filelocation;
//player.Play();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += timer_Tick;
timer.Start();
player.Source = new Uri(current.Filelocation, UriKind.Relative);
player.Position = now;
player.Play();
}
示例10: TitleScreenPage
public TitleScreenPage(Window win, MediaElement bgMusic)
{
main = win;
music = bgMusic;
InitializeComponent();
}
示例11: enemyMissile
public enemyMissile(double left, double top)
{
// use this to create the missile on the fly.
// calling function is going to supply the
// X Y Coordinate to create at.
// set up a rectangle
// fill in the values - background, picture,
StackPanel panel = new StackPanel();
Rectangle missileRect = new Rectangle();
missileRect.Height = 3;
missileRect.Width = 12;
missileRect.Fill = new SolidColorBrush(Colors.Black );
missileRect.Stroke = new SolidColorBrush(Colors.Yellow);
missileRect.RadiusX = 1;
missileRect.RadiusY = 1;
panel.Children.Add(missileRect);
MediaElement me = new MediaElement();
me.Source = new Uri("/laser.mp3", UriKind.Relative);
panel.Children.Add(me);
this.Content = panel;
Canvas.SetTop(this, top);
Canvas.SetLeft(this, left);
me.Play();
}
示例12: SetSourceAsync
public Task SetSourceAsync(IMediaStreamSource source)
{
return Dispatch(() =>
{
source.ValidateEvent(MediaStreamFsm.MediaEvent.MediaStreamSourceAssigned);
var wasSet = Interlocked.Exchange(ref _sourceIsSet, 1);
Debug.Assert(0 == wasSet);
if (null != _mediaElement)
{
UiThreadCleanup();
var mediaElement = _mediaElement;
_mediaElement = null;
_destroyMediaElement(mediaElement);
}
_mediaElement = _createMediaElement();
if (null != _mediaElement)
_mediaElement.SetSource((MediaStreamSource)source);
else
Debug.WriteLine("MediaElementManager.SetSourceAsync() null media element");
});
}
示例13: TV_Control
public TV_Control(MediaElement mE)
{
Messenger.Default.Register<int>(this, "EPGRequest_ChannelChange", EPG_Request);
delayChannelChangeTimer = new System.Timers.Timer(1000);
delayChannelChangeTimer.Elapsed += new ElapsedEventHandler(DelayedChannelChange);
this.mediaElement1 = mE;
}
示例14: WpfMediaPlayer
public WpfMediaPlayer(MediaElement mediaElement)
{
if (mediaElement == null)
throw new ArgumentNullException("mediaElement");
this.mediaElement = mediaElement;
}
示例15: MediaFile
public MediaFile(string path, DateTime startDate, DateTime endDate)
{
if (path == String.Empty)
{
throw new System.InvalidOperationException("Please enter a url for your media.");
}
else if (startDate == null || endDate == null)
{
throw new System.InvalidOperationException("Please enter a start and end date.");
}
this.url = path;
this.fileName = path.Split('\\').Last();
this.fileExt = fileName.Split('.').Last();
this.fileName = fileName.Split('.').First();
this.typeID = MediaFileUtilities.getFileTypeID(this.fileExt);
this.fileType = MediaFileUtilities.getFileType(this.fileExt);
MediaElement thisMediaFile = new MediaElement();
thisMediaFile.Source = new Uri(path);
this.width = (int)thisMediaFile.Width;
this.height = (int)thisMediaFile.Height;
this.dateStart = startDate;
this.dateEnd = endDate;
this.insertQuery = "INSERT INTO Media([url],[filename],[file_extension],[type_id],[width],[height],[date_start],[date_end])"
+ "VALUES ('" + url + "','" + fileName + "','" + fileExt + "','" + typeID + "','" + width + "','"
+ height + "','" + dateStart + "','" + dateEnd + "');";
}