Skip to content

Commit

Permalink
task: hide sample when not implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-rosa-knowcode authored and RafaelMendesRosa committed Aug 8, 2023
1 parent b943053 commit 0742e1c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Windows.Foundation.Metadata;
using Windows.Media.Core;
using Windows.Media.Playback;
using Microsoft.UI.Xaml;
Expand All @@ -19,16 +20,26 @@ public MediaPlayerElementSample_NestedPage5()

private void InitializePlaybackList()
{
var mediaPlaybackList = new MediaPlaybackList();

if (ApiInformation.IsPropertyPresent("Windows.Media.Playback.MediaPlaybackList", "Items"))
{
var mediaPlaybackList = new MediaPlaybackList();
mediaPlaybackList.Items.Add(new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/videos/Mobile_Development_in_VS_Code_with_Uno_Platform_orDotNetMAUI.mp4"))));
mediaPlaybackList.Items.Add(new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/audio/Getting_Started_with_Uno_Platform_and_Visual_Studio_Code.mp3"))));
mediaPlaybackList.Items.Add(new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/videos/Getting_Started_with_Uno_Platform_and_Visual_Studio_Code.mp4"))));

mediaPlaybackList.Items.Add(new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/videos/Mobile_Development_in_VS_Code_with_Uno_Platform_orDotNetMAUI.mp4"))));
mediaPlaybackList.Items.Add(new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/audio/Getting_Started_with_Uno_Platform_and_Visual_Studio_Code.mp3"))));
mediaPlaybackList.Items.Add(new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/videos/Getting_Started_with_Uno_Platform_and_Visual_Studio_Code.mp4"))));

MediaPlayerElementSample5.MediaPlayer.Source = mediaPlaybackList;
MediaPlayerElementSample5.MediaPlayer.Source = mediaPlaybackList;
}
else
{
if (MediaPlayerElementSample5.MediaPlayer == null)
{
MediaPlayerElementSample5.SetMediaPlayer(new Windows.Media.Playback.MediaPlayer());
}
MediaPlayerElementSample5.Source = MediaSource.CreateFromUri(new Uri("https://uno-assets.platform.uno/tests/videos/Mobile_Development_in_VS_Code_with_Uno_Platform_orDotNetMAUI.mp4"));
}
}


private void NavigateBack(object sender, RoutedEventArgs e)
{
MediaPlayerElementSample5.MediaPlayer.Pause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:SamplePageLayout>
<local:SamplePageLayout x:Name="LocalSamplePageLayout">
<local:SamplePageLayout.FluentTemplate>
<DataTemplate>
<StackPanel>
Expand Down Expand Up @@ -40,10 +40,12 @@
Click="LaunchMediaPlayerElementSample4"
Style="{StaticResource FilledButtonStyle}" />

<TextBlock Text="MediaPlayerElement sample using a Playlist"
Style="{StaticResource TitleLarge}"
Margin="0,16" />
<Button Content="Show sample"
<TextBlock Name="LaunchMediaPlayerElementSampleTextBlock5"
Text="MediaPlayerElement sample using a Playlist"
Style="{StaticResource TitleLarge}"
Margin="0,16" />
<Button Name="LaunchMediaPlayerElementSampleButton5"
Content="Show sample"
Click="LaunchMediaPlayerElementSample5"
Style="{StaticResource FilledButtonStyle}" />
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Uno.Gallery.Views.NestedPages;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml;
using Windows.Foundation.Metadata;
using Windows.UI.Xaml.Controls;

namespace Uno.Gallery.Views.Samples
{
Expand All @@ -10,6 +12,22 @@ public sealed partial class MediaPlayerElementSamplePage : Page
public MediaPlayerElementSamplePage()
{
this.InitializeComponent();
Loaded += MediaPlayerElementSamplePage_Loaded;
}

private void MediaPlayerElementSamplePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (!ApiInformation.IsPropertyPresent("Windows.Media.Playback.MediaPlaybackList", "Items"))
{
Button buttonSampleButton5 = (Button)LocalSamplePageLayout.FindName("LaunchMediaPlayerElementSampleButton5");
TextBlock textBlockSampleButton5 = (TextBlock)LocalSamplePageLayout.FindName("LaunchMediaPlayerElementSampleTextBlock5");
if (buttonSampleButton5 != null && textBlockSampleButton5 != null)
{
buttonSampleButton5.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
textBlockSampleButton5.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
}

}

private void LaunchMediaPlayerElementSample1(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 0742e1c

Please sign in to comment.