I\'m struggling with the following issue:
I am building a WP8 application using the MVVM patern. I have a media element on my view.xaml and the logic to control this med
The answer of asitis is great.And I show you my detail code:(use caliburn.micro so don't need to bind name)
View
ViewModel
private MediaElement _mediaElementObject = new MediaElement();
public MediaElement MediaElementObject
{
get { return _mediaElementObject; }
set
{
_mediaElementObject = value;
NotifyOfPropertyChange(() => MediaElementObject);
}
}
public void ButtonPlay()
{
MediaElementObject.Source =new Uri( @"C:\Users\admin\Videos\XXXXXX.wmv");
MediaElementObject.LoadedBehavior = MediaState.Manual;
MediaElementObject.UnloadedBehavior = MediaState.Manual;
MediaElementObject.Play();
}
public void ButtonStop()
{
MediaElementObject.Stop();
}
public void ButtonForward()
{
MediaElementObject.Position = _mediaElementObject.Position + TimeSpan.FromSeconds(30);
}
public void ButtonBack()
{
MediaElementObject.Position = _mediaElementObject.Position - TimeSpan.FromSeconds(30);
}
May can help someone:)