Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ public partial class MediaElementPage : BasePage<MediaElementViewModel>
{
const string loadOnlineMp4 = "Load Online MP4";
const string loadHls = "Load HTTP Live Stream (HLS)";
const string loadDASH = "Load MPEG-DASH (not supported on iOS/MacCatalyst)";
const string loadLocalResource = "Load Local Resource";
const string resetSource = "Reset Source to null";
const string loadMusic = "Load Music";

const string botImageUrl = "https://lh3.googleusercontent.com/pw/AP1GczNRrebWCJvfdIau1EbsyyYiwAfwHS0JXjbioXvHqEwYIIdCzuLodQCZmA57GADIo5iB3yMMx3t_vsefbfoHwSg0jfUjIXaI83xpiih6d-oT7qD_slR0VgNtfAwJhDBU09kS5V2T5ZML-WWZn8IrjD4J-g=w1792-h1024-s-no-gm";
const string hlsStreamTestUrl = "https://mtoczko.github.io/hls-test-streams/test-gap/playlist.m3u8";
const string dashTestUrl = "https://livesim.dashif.org/dash/vod/testpic_2s/multi_subs.mpd";
const string hal9000AudioUrl = "https://github.com/prof3ssorSt3v3/media-sample-files/raw/master/hal-9000.mp3";


readonly ILogger logger;
readonly IDeviceInfo deviceInfo;
readonly IFileSystem fileSystem;
Expand Down Expand Up @@ -166,7 +167,7 @@ void Button_Clicked(object? sender, EventArgs e)
async void ChangeSourceClicked(Object sender, EventArgs e)
{
var result = await DisplayActionSheet("Choose a source", "Cancel", null,
loadOnlineMp4, loadHls, loadLocalResource, resetSource, loadMusic);
loadOnlineMp4, loadHls, loadDASH, loadLocalResource, resetSource, loadMusic);

MediaElement.Stop();
MediaElement.Source = null;
Expand All @@ -188,6 +189,12 @@ async void ChangeSourceClicked(Object sender, EventArgs e)
MediaElement.Source = MediaSource.FromUri(hlsStreamTestUrl);
return;

case loadDASH:
MediaElement.MetadataArtist = "DASH Album";
MediaElement.MetadataArtworkUrl = botImageUrl;
MediaElement.MetadataTitle = "DASH Title";
MediaElement.Source = MediaSource.FromUri(dashTestUrl);
return;
case resetSource:
MediaElement.MetadataArtworkUrl = string.Empty;
MediaElement.MetadataTitle = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public static MauiAppBuilder UseMauiCommunityToolkitMediaElement(this MauiAppBui
h.AddHandler<MediaElement, MediaElementHandler>();
});

#if ANDROID
builder.Services.AddSingleton<Media.Services.MediaControlsService>();
#endif

return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@ protected override MauiMediaElement CreatePlatformView()
VirtualView,
Dispatcher.GetForCurrentThread() ?? throw new InvalidOperationException($"{nameof(IDispatcher)} cannot be null"));

var (_, playerView) = MediaManager.CreatePlatformView(VirtualView.AndroidViewType);
var playerView = MediaManager.CreatePlatformView(VirtualView.AndroidViewType);
return new(Context, playerView);
}

protected override async void ConnectHandler(MauiMediaElement platformView)
{
base.ConnectHandler(platformView);
if(platformView is null)
{
throw new InvalidOperationException($"{nameof(platformView)} cannot be null");
}
if (MediaManager is null)
{
throw new InvalidOperationException($"{nameof(MediaManager)} cannot be null");
}
var mediaController = await MediaManager.CreateMediaController();
platformView?.SetView(mediaController);
await MediaManager.UpdateSource();
}
protected override void DisconnectHandler(MauiMediaElement platformView)
{
platformView.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/texture_view_media_element"
app:surface_type="texture_view"
app:shutter_background_color="#FFFFFF"
app:shutter_background_color="#000000"
android:layout_width= "match_parent"
android:layout_height= "match_parent"
android:background="@android:color/transparent"
android:background="@android:color/black"
/>

This file was deleted.

This file was deleted.

Loading
Loading