Skip to content

Windows: Sound not playing - missing PresentationCore assembly #6

Description

@akshay1845

Bug Description

The extension doesn't play sound on Windows because the PowerShell command is missing the required PresentationCore
assembly import.

Environment

  • OS: Windows
  • Extension Version: 0.0.4

Root Cause

In dist/extension.js (line 103), the Windows sound playback command is:

cmd = `powershell -c "$p = New-Object System.Windows.Media.MediaPlayer; $p.Open('${filePath}'); $p.Play(); Start-Sleep  
3"`;

The System.Windows.Media.MediaPlayer class requires the PresentationCore assembly to be loaded first.

Error

When the extension tries to play sound, PowerShell throws:
Cannot find type [System.Windows.Media.MediaPlayer]: verify that the assembly containing this type is loaded.

Fix

Add Add-Type -AssemblyName PresentationCore; before creating the MediaPlayer object:

cmd = `powershell -c "Add-Type -AssemblyName PresentationCore; $p = New-Object System.Windows.Media.MediaPlayer;        
$p.Open('${filePath}'); $p.Play(); Start-Sleep 3"`;

This fix has been tested and confirmed working on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions