2
$\begingroup$

With Mathematica 12.2 I can import a sound file like this:

f = Import["F:\\mysound.mp3", "Sound"]; 

and play it like this:

EmitSound[f]]; 

But how can I get it to play, and once only, at a scheduled time?

I've tried running this:

RunScheduledTask[EmitSound[f], {1}, AbsoluteTime[{2022, 4, 6, 22, 12, 0}]] 

but it doesn't do anything. I'm guessing this is because it runs once and then by the time the scheduled moment comes it isn't running.

Many thanks for any help with this.

(The deleter clicked to send a message saying "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." Thanks, deleter. And what was the trivial syntax error, incorrect capitalisation, spelling mistake, other simple mistake, or easily found page in the documentation?)

$\endgroup$
2
  • 2
    $\begingroup$ Well, first off, the documentation for RunScheduledTask indicates that it's obsolete and you should use TaskExecute. But, just running some experiments, I think that the behavior is different from the documentation, because if I use RunScheduledTask with a 1 as the last argument (instead of your AbsoluteTime argument), the task runs 1 second after I evaluate the expression. So, that last argument seems to be a delay from now rather than an absolute time. $\endgroup$ Commented Apr 6, 2022 at 21:31
  • 2
    $\begingroup$ @lericr - Many thanks for this. This suggests an argument such as AbsoluteTime[{2022, 4, 6, 22, 12, 0}]]-AbsoluteTime[Now], which works fine. $\endgroup$ Commented Apr 6, 2022 at 22:33

0