{"id":2387,"date":"2025-04-15T12:57:14","date_gmt":"2025-04-15T11:57:14","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=2387"},"modified":"2025-04-19T19:04:12","modified_gmt":"2025-04-19T18:04:12","slug":"shadertoy-net-maui-communitytoolkit-mediaelement","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/2387","title":{"rendered":"Shadertoy &amp; .NET MAUI CommunityToolkit MediaElement"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A side effect from integration of external video signal coming from native code C++ application with a <a href=\"https:\/\/dotnet.microsoft.com\/en-us\/learn\/aspnet\/blazor-tutorial\/intro\">.NET MAUI Blazor app<\/a>: a reference video source (based on nice <a href=\"https:\/\/www.shadertoy.com\/view\/mtyGWy\">Shader Art Coding Introduction<\/a> shadertoy &#8211; an HLSL equivalent can be found in resources of the attached application) is taken into <a href=\"https:\/\/github.com\/CommunityToolkit\/Maui\/tree\/main\/samples\/CommunityToolkit.Maui.Sample\/ViewModels\/Views\/MediaElement\">.NET MAUI CommunityToolkit <code>MediaElement<\/code><\/a> control (see also <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-dotnet-maui-communitytoolkit-mediaelement\/\">Play Audio and Video in .NET MAUI apps with the new MediaElement<\/a>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The application below is a reduced version to simply put the video source into a slim C++ application, see <a href=\"https:\/\/github.com\/robmikh\/CompositionVideoDemo\">this tiny <code>CompositionVideoDemo<\/code> application<\/a> if you are curious how to host a <code><a href=\"https:\/\/learn.microsoft.com\/en-us\/uwp\/api\/windows.media.core.mediasource\">Windows.Media.Core.MediaSource<\/a><\/code> instance in a C++ application.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"539\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-800x539.png\" alt=\"\" class=\"wp-image-2389\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-800x539.png 800w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-320x216.png 320w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-768x517.png 768w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-600x404.png 600w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1040x701.png 1040w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image.png 1247w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-5cf0ebc0-6946-4de3-8e2c-5d61e3b51397\" href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/MediaPlayer-20250415-a02d61b69a12ea0533141f9a479041db1b6c55f3.zip\">MediaPlayer-20250415-a02d61b69a12ea0533141f9a479041db1b6c55f3<\/a><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/MediaPlayer-20250415-a02d61b69a12ea0533141f9a479041db1b6c55f3.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-5cf0ebc0-6946-4de3-8e2c-5d61e3b51397\">Download<\/a><\/div>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">There is full hardware video acceleration of course, the live video is rendered directly by the shader to a Direct3D 11 device. Then the signal transits into the control bypassing system memory, hence minimal CPU load and reasonable GPU load on its 3D engine. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"512\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-800x512.png\" alt=\"\" class=\"wp-image-2390\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-800x512.png 800w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-320x205.png 320w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-768x492.png 768w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-1536x984.png 1536w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-2048x1312.png 2048w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-600x384.png 600w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-1-1040x666.png 1040w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After all\u2026 here we go in the Blazor\/MAUI application:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"400\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-800x400.png\" alt=\"\" class=\"wp-image-2392\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-800x400.png 800w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-320x160.png 320w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-768x384.png 768w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-1536x768.png 1536w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-600x300.png 600w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2-1040x520.png 1040w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2025\/04\/image-2.png 1977w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>A side effect from integration of external video signal coming from native code C++ application with a .NET MAUI Blazor app: a reference video source (based on nice Shader Art Coding Introduction shadertoy &#8211; an HLSL equivalent can be found in resources of the attached application) is taken into .NET MAUI CommunityToolkit MediaElement control (see&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/2387\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[538,643,38,642,424,579,486],"class_list":["post-2387","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-net","tag-blazor","tag-c","tag-maui","tag-media-foundation","tag-shadertoy","tag-video"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/2387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=2387"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/2387\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=2387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=2387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=2387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}