{"id":148,"date":"2017-10-09T09:00:32","date_gmt":"2017-10-09T09:00:32","guid":{"rendered":"http:\/\/larrybuffaloboy.com\/?p=148"},"modified":"2017-10-09T09:00:32","modified_gmt":"2017-10-09T09:00:32","slug":"music-alarm-script","status":"publish","type":"post","link":"https:\/\/larrybuffaloboy.com\/index.php\/2017\/10\/09\/music-alarm-script\/","title":{"rendered":"Music Alarm Script"},"content":{"rendered":"<p>A friend asked me to create a script that will play music for him in the morning when he wants to wake up. I used powershell and created something that works, for the most part. Testing it overnight had some bugs, looks like it didn&#8217;t want to wake up on its own. I need to work out the kinks&#8230;<\/p>\n<pre><code>$filepath = (get-location).Path\necho 'What time do you want to wake up? Example \"00:00 AM\". Enter Below:'\n$userTime = Read-Host\nclear\necho \"Alarm Set for $userTime\"\n$song = Get-ChildItem -Path \"$filepath\\musicToPlay\" -Include \"*mp3\" -Recurse\n$timeWait = New-Timespan -End $userTime\n\nStart-Sleep -s $timeWait.TotalSeconds\n\nAdd-Type -AssemblyName presentationCore\n $song | foreach {\n    $wmplayer = New-Object System.Windows.Media.MediaPlayer\n    $timeNow = Get-Date -Format g\n    echo \"The time is now $timeNow\"\n\n    echo (\"About to play: \" + $_.Name)\n    $wmplayer.Open(\"$_\")\n    Start-Sleep 2 # This allows the $wmplayer time to load the audio file\n    $duration = $wmplayer.NaturalDuration.TimeSpan.TotalSeconds\n    $wmplayer.Play()\n    echo (\"Playing \" + $_.Name + \"......\")\n    echo (\"Duration == \" + $duration)\n    Start-Sleep $duration\n    $wmplayer.Stop()\n    $wmplayer.Close()\n }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A friend asked me to create a script that will play music for him in the morning when he wants to wake up. I used powershell and created something that works, for the most part. Testing it overnight had some bugs, looks like it didn&#8217;t want to wake up on its own. I need to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/posts\/148"}],"collection":[{"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":0,"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"wp:attachment":[{"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/larrybuffaloboy.com\/index.php\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}