Skip to content

Fix Windows Media Source bug with Packaged Apps #2609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ne0rrmatrix
Copy link
Contributor

Description of Change

This fixes a bug in Windows where running an app in packaged mode results in media element not finding package resources and failing to playback Media Source from resource directory.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

To test this change run sample app in packaged and unpackaged mode and load local resource from drop down menu in sample app. It fixes an issue where running app as packaged results in failed media playback when choosing local resource from menu.

I added two Microsoft internal classes and I used null forgiveness operator. I know that is not allowed and would love it if someone could tell me if I should just rewrite the internals or just do the minimum to have it compile. Currently I only made the adjustments to let the app compile. I am happy to fix the use of null operator but I wanted feedback before modifying MS internals.

@Copilot Copilot AI review requested due to automatic review settings April 1, 2025 14:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug on Windows where media playback fails in packaged mode by ensuring that the MediaElement correctly retrieves package resources.

  • Added a null and whitespace check on ResourceMediaSource.Path before constructing the file path.
  • Introduced two new helper classes (FileSystemUtils and AppInfoUtils) to retrieve and normalize the app package file path on Windows.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
MediaManager.windows.cs Adds a Path check and uses PlatformGetFullAppPackageFilePath to correctly obtain a media file’s URI.
FileSystemUtils.windows.cs Introduces file path normalization and retrieval methods to support packaged app scenarios.
AppInfoUtils.windows.cs Implements app info utilities, including packaged app detection and version retrieval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] 6.0.1 MedialElement doesn't display / load embedded source
2 participants