Search code examples
xamlwinrt-xamlwindows-10-universalmediaelementwindows-media-player

Removing the broadcasting icon when player is in fullscreen on MediaElement


I am using the default MediaElement with AreTransportControlsEnabled="True" and I am trying to remove the CastButton element when the app is in full screen.

I have already created a copy of MediaTransportControls and commented out the CastButton but this doesn't work when in fullscreen any ideas?

Here is the sample project attached: https://www.dropbox.com/s/83wt4adr8db7xqu/App1.zip?dl=0

My code :

  <Style TargetType="MediaTransportControls">
bla bla
 <ControlTemplate TargetType="MediaTransportControls">
bla
  <!--<AppBarButton x:Name='CastButton'
           Style='{StaticResource AppBarButtonStyle}'
           Visibility="Collapsed"
           MediaTransportControlsHelper.DropoutOrder='7'>
                     <AppBarButton.Icon>
                           <FontIcon Glyph="&#xEC15;"/>
          </AppBarButton>-->

bla bla

My MediaElement:

     <MediaElement Source="http://smf.blob.core.windows.net/samples/videos/bigbuck.mp4"
                          AreTransportControlsEnabled="True"
                          ></MediaElement>

Solution

  • You're almost done correctly. The main reason that your xaml wasn't merged in global dictionary your application. Just move you xaml code:

    1. To App.xaml
    2. Or create some file, which will be contains you style and merge this xaml style with resource dictionary in App.xaml

    You can see it by code bellow:

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Styles/MediaElementStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
    

    I did it through second way. Your project link