Skip to content

[Bug] Conflicts with K-Lite Codec Pack on Windows (throw PlatformException) #1952

Description

@WHYBBE

When the K-Lite Codec Pack is installed on my Windows computer and overrides the default Windows codecs, the audioplayers do not work properly.(packages/audioplayers/example with audioplayers-v6.5.0)

Issue

The main error issues:

  • Some audio cannot be played properly.
  • The app crashes when playing some audio.

Key error message: Unhandled Exception: PlatformException(WindowsAudioError, Failed to set source

Detailed error information:

[ERROR:flutter/shell/common/shell.cc(1120)] The 'xyz.luan/audioplayers/events/732d39c7-588e-4816-9bec-54993bb426b4' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
AudioPlayers Exception: AudioPlayerException(
	UrlSource(url: https://luan.xyz/files/audio/coins.wav, mimeType: null), 
	PlatformException(WindowsAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, , null)
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(WindowsAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, , null)

[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(WindowsAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, , null)

Related Code

// audioplayers\packages\audioplayers_windows\windows\audio_player.cpp
try {
      // Create a source resolver to create an IMFMediaSource for the content
      // URL. This will create an instance of an inbuilt OS media source for
      // playback. An application can skip this step and instantiate a custom
      // IMFMediaSource implementation instead.
      winrt::com_ptr<IMFSourceResolver> sourceResolver;
      THROW_IF_FAILED(MFCreateSourceResolver(sourceResolver.put()));
      constexpr uint32_t sourceResolutionFlags =
          MF_RESOLUTION_MEDIASOURCE |
          MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE |
          MF_RESOLUTION_READ;
      MF_OBJECT_TYPE objectType = {};

      winrt::com_ptr<IMFMediaSource> mediaSource;

// throw error position
      THROW_IF_FAILED(sourceResolver->CreateObjectFromURL(
          winrt::to_hstring(url).c_str(), sourceResolutionFlags, nullptr,
          &objectType, reinterpret_cast<IUnknown**>(mediaSource.put_void())));

      m_mediaEngineWrapper->SetMediaSource(mediaSource.get());
    }

Environment

Codec Tweak Tool(Media Foundation)

Image

especially wav

Image

Workaround

Disable the prohibition of WAV in Codec Tweak Tool.

Image

Expectation

There are better ways to coexist with K-Lite Codec Pack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions