{"id":37477,"date":"2024-11-01T09:57:53","date_gmt":"2024-11-01T09:57:53","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37477"},"modified":"2024-11-01T11:02:34","modified_gmt":"2024-11-01T11:02:34","slug":"uwp-development-media","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37477\/","title":{"rendered":"UWP Development, Media"},"content":{"rendered":"<p>The Windows Universal Platform (UWP) is a powerful platform that allows developers to create applications for a variety of Windows devices. UWP provides APIs that make it particularly easy to handle multimedia content. In this article, we will explore the media-related capabilities of UWP and introduce how to create a real application through code examples.<\/p>\n<h2>1. Overview of UWP Media APIs<\/h2>\n<p>UWP offers a variety of APIs that support the following media operations:<\/p>\n<ul>\n<li><strong>Video and Audio Playback:<\/strong> You can play video and audio files using <code>MediaElement<\/code>.<\/li>\n<li><strong>Media Streaming:<\/strong> You can play streaming media using <code>MediaPlaybackItem<\/code>.<\/li>\n<li><strong>Exploring Media Libraries:<\/strong> You can explore the user&#8217;s media library using the <code>Windows.Storage<\/code> API.<\/li>\n<\/ul>\n<h2>2. Using MediaElement<\/h2>\n<p><code>MediaElement<\/code> is the primary control used to play video and audio in UWP applications. Below is a simple example of playing video using <code>MediaElement<\/code>.<\/p>\n<h3>2.1 Declaring MediaElement in XAML<\/h3>\n<pre>\n<code>&lt;Grid Background=\"White\"&gt;\n    &lt;MediaElement x:Name=\"MyMediaElement\" \n                   AutoPlay=\"False\" \n                   AreTransportControlsEnabled=\"True\"\/&gt;\n    &lt;Button Content=\"Play Video\" \n            Click=\"PlayButton_Click\" \n            HorizontalAlignment=\"Center\" \n            VerticalAlignment=\"Bottom\" \/&gt;\n&lt;\/Grid&gt;\n<\/code>\n<\/pre>\n<h3>2.2 Playing Video with C# Code<\/h3>\n<pre>\n<code>private void PlayButton_Click(object sender, RoutedEventArgs e)\n{\n    Uri videoUri = new Uri(\"ms-appx:\/\/\/Assets\/sample.mp4\");\n    MyMediaElement.Source = MediaSource.CreateFromUri(videoUri);\n    MyMediaElement.Play();\n}\n<\/code>\n<\/pre>\n<h2>3. Advanced Features of Video Playback<\/h2>\n<p>In addition to basic video playback capabilities, UWP offers more features. Here are some advanced features that enhance the user experience of media playback:<\/p>\n<ul>\n<li><strong>Media Playback Controls:<\/strong> Users can easily use controls such as pause, resume, and seek.<\/li>\n<li><strong>Media State Events:<\/strong> Events are provided to monitor the state of media playback and detect changes.<\/li>\n<\/ul>\n<h3>3.1 Handling Playback State Events<\/h3>\n<pre>\n<code>private void MyMediaElement_CurrentStateChanged(object sender, RoutedEventArgs e)\n{\n    switch (MyMediaElement.CurrentState)\n    {\n        case MediaElementState.Playing:\n            \/\/ Handling when the video is playing\n            break;\n        case MediaElementState.Paused:\n            \/\/ Handling when the video is paused\n            break;\n        case MediaElementState.Stopped:\n            \/\/ Handling when the video is stopped\n            break;\n    }\n}\n<\/code>\n<\/pre>\n<h2>4. Media Playback Items<\/h2>\n<p>In UWP, you can handle the streaming and playback of media content using <code>MediaPlaybackItem<\/code>. This API is useful for managing more complex media playlists.<\/p>\n<h3>4.1 Using MediaPlaybackItem<\/h3>\n<pre>\n<code>private void LoadMedia()\n{\n    var videoUri = new Uri(\"ms-appx:\/\/\/Assets\/sample.mp4\");\n    var playbackItem = new MediaPlaybackItem(MediaSource.CreateFromUri(videoUri));\n    \n    var mediaPlayer = new MediaPlayer();\n    mediaPlayer.PlaybackSession.PlaybackStateChanged += PlaybackSession_PlaybackStateChanged;\n    mediaPlayer.Source = MediaSource.CreateFromPlaybackItems(new[] { playbackItem });\n    mediaPlayer.Play();\n}\n<\/code>\n<\/pre>\n<h2>5. Accessing Media Library<\/h2>\n<p>UWP provides an API that allows access to the user&#8217;s media library. This makes it easy to explore and play the user&#8217;s video and music files.<\/p>\n<h3>5.1 Requesting Access to Media Files<\/h3>\n<pre>\n<code>private async Task RequestMediaLibraryAccess()\n{\n    var accessStatus = await Windows.Storage.AccessCache.StorageApplicationPermissions.RequestAccessAsync();\n    if (accessStatus == Windows.Storage.AccessCache.AccessStatus.Allowed)\n    {\n        \/\/ Access granted\n    }\n}\n<\/code>\n<\/pre>\n<h3>5.2 Exploring and Playing Media Files<\/h3>\n<pre>\n<code>private async Task LoadMediaFiles()\n{\n    var folder = KnownFolders.MusicLibrary;\n    var files = await folder.GetFilesAsync();\n    foreach (var file in files)\n    {\n        \/\/ response with mediaSource\n        var mediaSource = MediaSource.CreateFromStorageFile(file);\n        MyMediaElement.Source = mediaSource;\n        MyMediaElement.Play();\n    }\n}\n<\/code>\n<\/pre>\n<h2>6. Conclusion<\/h2>\n<p>Implementing media functionality through UWP development is relatively intuitive and can be utilized in various applications. In this tutorial, we introduced <code>MediaElement<\/code>, <code>MediaPlaybackItem<\/code>, and how to access the media library. Based on this foundational knowledge, try developing your own multimedia applications. Take your next step and work on an exciting project!<\/p>\n<p>Finally, it is recommended to refer to Microsoft&#8217;s official documentation for more information and resources on UWP media development. In the next article, we will cover more advanced topics, so stay tuned!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Windows Universal Platform (UWP) is a powerful platform that allows developers to create applications for a variety of Windows devices. UWP provides APIs that make it particularly easy to handle multimedia content. In this article, we will explore the media-related capabilities of UWP and introduce how to create a real application through code examples. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37477\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;UWP Development, Media&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[115],"tags":[],"class_list":["post-37477","post","type-post","status-publish","format-standard","hentry","category-uwp-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>UWP Development, Media - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37477\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UWP Development, Media - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"The Windows Universal Platform (UWP) is a powerful platform that allows developers to create applications for a variety of Windows devices. UWP provides APIs that make it particularly easy to handle multimedia content. In this article, we will explore the media-related capabilities of UWP and introduce how to create a real application through code examples. &hellip; \ub354 \ubcf4\uae30 &quot;UWP Development, Media&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37477\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:57:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:02:34+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37477\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37477\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"UWP Development, Media\",\"datePublished\":\"2024-11-01T09:57:53+00:00\",\"dateModified\":\"2024-11-01T11:02:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37477\/\"},\"wordCount\":357,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"UWP Programming\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37477\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37477\/\",\"name\":\"UWP Development, Media - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:57:53+00:00\",\"dateModified\":\"2024-11-01T11:02:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37477\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37477\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37477\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UWP Development, Media\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UWP Development, Media - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37477\/","og_locale":"ko_KR","og_type":"article","og_title":"UWP Development, Media - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"The Windows Universal Platform (UWP) is a powerful platform that allows developers to create applications for a variety of Windows devices. UWP provides APIs that make it particularly easy to handle multimedia content. In this article, we will explore the media-related capabilities of UWP and introduce how to create a real application through code examples. &hellip; \ub354 \ubcf4\uae30 \"UWP Development, Media\"","og_url":"https:\/\/atmokpo.com\/w\/37477\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:57:53+00:00","article_modified_time":"2024-11-01T11:02:34+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37477\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37477\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"UWP Development, Media","datePublished":"2024-11-01T09:57:53+00:00","dateModified":"2024-11-01T11:02:34+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37477\/"},"wordCount":357,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["UWP Programming"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37477\/","url":"https:\/\/atmokpo.com\/w\/37477\/","name":"UWP Development, Media - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:57:53+00:00","dateModified":"2024-11-01T11:02:34+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37477\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37477\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37477\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"UWP Development, Media"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37477"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37477\/revisions"}],"predecessor-version":[{"id":37478,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37477\/revisions\/37478"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}