locked
How to put a viewable UI control like MediaPlayer in App.xaml or a page with global scope? RRS feed

  • Question

  • In other words, how to add a globally viewable UI control? I want my MediaPlayer to be displayed at the top or bottom of each page. I tried putting MediaElement in App.xaml and I could play audio globally on all my app pages, but since MediaElement is more abstract version of MediaPlayer and has no interface, i'll have to explicitly make play pause controls for every page which is not convenient...

    I want something like the Music app bottom bar 'now playing' in the consumer preview...


    -Sagar

    Sunday, April 15, 2012 1:07 PM

Answers

  • Hi Sagar_sm,

    I would suggest using a MediaPlayer and a Frame control to build the startup page. And use that Frame control to load your pages. So the MediaPlayer will always be there.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Min ZhuMember Monday, April 30, 2012 9:40 AM
    Monday, April 16, 2012 1:54 AM
    Moderator

All replies

  • Hi Sagar_sm,

    I would suggest using a MediaPlayer and a Frame control to build the startup page. And use that Frame control to load your pages. So the MediaPlayer will always be there.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Min ZhuMember Monday, April 30, 2012 9:40 AM
    Monday, April 16, 2012 1:54 AM
    Moderator
  • hi

    I m still confused on how to do it... can u pls provide some code sample or divert me to a link?


    -Sagar

    Tuesday, April 17, 2012 10:29 AM
  • Hi Sagar,

    Below is a very simple demonstration.

    BlankPage.xaml

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Frame x:Name="myFrame"/>
            <MediaPlayer Grid.Row="1"/>
        </Grid>


            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                myFrame.Navigate(typeof(Page1));
            }

    Page1.xaml

        <Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
            <Button Content="GoToPage2" Click="Button_Click_1"/>
        </Grid>


            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                this.Frame.Navigate(typeof(Page2));
            }

    Page2.xaml

        <Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
            <Button Content="GoToPage1" Click="Button_Click_1"/>
        </Grid>


            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                this.Frame.Navigate(typeof(Page1));
            }

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, April 18, 2012 1:27 AM
    Moderator