yamcs / yamcs-studio

Desktop TM/TC Client for Yamcs
https://docs.yamcs.org/yamcs-studio/
Eclipse Public License 2.0
27 stars 14 forks source link

Play wav problems #97

Closed nmaas87 closed 3 years ago

nmaas87 commented 3 years ago

I am using Studio 1.5.3 and tried to play a wav file via Javascript. I tried to write something like

importPackage(Packages.org.csstudio.opibuilder.scriptUtil);
importPackage(Packages.org.csstudio.opibuilder.FileUtil);
playWavFile("F:\test.wav","");

but that gave me an "error in your script" - I guess I did something wrong here.

However, I also tried the "Play a wav file on execute" with this Test file: https://www.kozco.com/tech/piano2.wav - but it did not work. It did not show any error, but also I did not hear any sound playing as soon as I clicked.

could you help me out with both?

Thanks a lot :)!

fqqb commented 3 years ago

Try this:

FileUtil.playWavFile("F:\test.wav", null);

Or even better, put the file in your workspace and then use a relative path (relative to the widget's OPI)

FileUtil.playWavFile("test.wav", widget);

btw importPackage is done automatically for the utils. It's harmless, but you can also get rid of it.

nmaas87 commented 3 years ago

Thank you Fabian. First solution produced a popup with

Play wave file has encountered a problem
An internal error occurred during: "Play wave file".
java.lang.NullPointerException

however, I thought maybe the test wave file is somewhat different, so I downloaded a new one from here: http://horton.com/consulting/portfolio/dwbt/bouncer/media/sample.wav - and I tried it again.

To sum up: a) wav files with too high of a bandwidth will fail, so I changed to using the sample.wav b) I messed up, on Windows you need to use / spaces, i.e.

FileUtil.playWavFile("F:/sample.wav", null);

works,

FileUtil.playWavFile("F:\sample.wav", null);

will fail with the NullPointer

c) using the

FileUtil.playWavFile("sample.wav", widget);

will then also work :)

Thank you very much :)!