Control Player Framework from anothers Views

Topics: Windows 8 Xaml
Sep 24, 2013 at 12:12 PM
Hi,

I have an app and on a xaml file i have the mediaplayer object who gets playing some stream behind anothers xaml files (it's a kind of stream background).

It's possible control that Player from another xaml file? I'm using MVVM, and the app is Windows 8 app.

thanks.
Coordinator
Sep 25, 2013 at 1:23 AM
The player framework is regular control just like a Button or TextBlock so this is certainly possibly as long as you find a way to pass along the instance of the MediaPlayer control to your other page. Everything you can set and control through Xaml can also be controlled via code.

Hope this helps a little.
Sep 25, 2013 at 9:31 AM
Hi,

i resolve my problem, but i need create the MediaPlayer Framework on codeBehind.
 public static MediaPlayer MediaPlayer = new MediaPlayer();

public MasterPage()
        {
            InitializeComponent();
            Init();
        }

private void Init()
        {
            MediaPlayer.Width = StreamGrid.Width;
            MediaPlayer.Height = StreamGrid.Height;

            StreamGrid.Children.Add(MediaPlayer);

            MediaPlayer.Source = new Uri("http:\\.....");
            MediaPlayer.Play();
}

internal static void StopStream()
        {
            MediaPlayer.Stop();
        }

        internal static void SetMediaPlayerSource(string source)
        {
            MediaPlayer.Source = new Uri(source);
        }

        internal static void PlayStream(object sender, RoutedEventArgs e)
        {
            MediaPlayer.PlayResume(); 
            //MediaPlayer.Play();
        }

        internal static void ReplayStream(object sender, RoutedEventArgs e)
        {
            MediaPlayer.PlaybackRate = -12;
        }

        internal static void RewindStream(object sender, RoutedEventArgs e)
        {
            MediaPlayer.PlaybackRate = -6;
        }

        internal static void SkipForwardStream(object sender, RoutedEventArgs e)
        {
            MediaPlayer.PlaybackRate = 6;
        }

        internal static void FastForwardStream(object sender, RoutedEventArgs e)
        {
            MediaPlayer.PlaybackRate = 12;
        }
thanks.