From ee4ae3a42d5cc1dd77983c810f7dfb426b0fbb43 Mon Sep 17 00:00:00 2001 From: Josh King Date: Fri, 26 Apr 2024 15:10:10 +1200 Subject: [PATCH] (breaking) Remove custom audio path The ability to point to your own sound files was removed by Microsoft several years ago and has been deprecated in BurntToast for almost as long. This means only built in system sounds can be used now. --- Tests/New-BTAudio.Tests.ps1 | 10 ---------- src/Private/Test-BTAudioPath.ps1 | 27 --------------------------- src/Public/New-BTAudio.ps1 | 19 ------------------- 3 files changed, 56 deletions(-) delete mode 100644 src/Private/Test-BTAudioPath.ps1 diff --git a/Tests/New-BTAudio.Tests.ps1 b/Tests/New-BTAudio.Tests.ps1 index 34948b6..e87cf8a 100644 --- a/Tests/New-BTAudio.Tests.ps1 +++ b/Tests/New-BTAudio.Tests.ps1 @@ -48,14 +48,4 @@ Describe 'New-BTAudio' { $Log | Should -Be $Expected } } - - Context 'input validation' { - It 'throws if audio file doesn''t exist' { - { New-BTAudio -Path 'C:\Fake\phantom.wav' } | Should -Throw "Cannot validate argument on parameter 'Path'. The file 'C:\Fake\phantom.wav' doesn't exist in the specified location. Please provide a valid path and try again." - } - - It 'throws if the extension is not supported' { - { New-BTAudio -Path 'C:\Fake\phantom.mov' } | Should -Throw "Cannot validate argument on parameter 'Path'. The file extension '.mov' is not supported. Please provide a valid path and try again." - } - } } diff --git a/src/Private/Test-BTAudioPath.ps1 b/src/Private/Test-BTAudioPath.ps1 deleted file mode 100644 index 08ef81e..0000000 --- a/src/Private/Test-BTAudioPath.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -function Test-BTAudioPath { - param ( - [Parameter(Mandatory)] - [String] $Path - ) - - $Extension = [IO.Path]::GetExtension($Path) - - $ValidExtensions = @( - '.aac' - '.flac' - '.m4a' - '.mp3' - '.wav' - '.wma' - ) - - if ($Extension -in $ValidExtensions) { - if (Test-Path -Path $Path) { - $true - } else { - throw "The file '$Path' doesn't exist in the specified location. Please provide a valid path and try again." - } - } else { - throw "The file extension '$Extension' is not supported. Please provide a valid path and try again." - } -} diff --git a/src/Public/New-BTAudio.ps1 b/src/Public/New-BTAudio.ps1 index 3f23f9e..0c8d38c 100644 --- a/src/Public/New-BTAudio.ps1 +++ b/src/Public/New-BTAudio.ps1 @@ -72,22 +72,7 @@ 'ms-winsoundevent:Notification.Looping.Call10')] [uri] $Source, - # The full path to an audio file. Supported file types include: - # - # *.aac - # *.flac - # *.m4a - # *.mp3 - # *.wav - # *.wma - [Parameter(Mandatory, - ParameterSetName = 'CustomSound')] - [ValidateScript({Test-BTAudioPath $_})] - [Obsolete('Unfortunately, custom sounds no longer work and this parameter will be removed in v0.9.0. See: https://github.com/MicrosoftDocs/windows-uwp/issues/1593')] - [string] $Path, - # Specifies that the slected sound should play multiple times if its duration is shorter than that of the toast it accompanies. - [Parameter(ParameterSetName = 'CustomSound')] [Parameter(ParameterSetName = 'StandardSound')] [switch] $Loop, @@ -103,10 +88,6 @@ $Audio.Src = $Source } - if ($Path) { - $Audio.Src = $Path - } - $Audio.Loop = $Loop $Audio.Silent = $Silent