mvf / qolibri

Continuation of the qolibri EPWING dictionary/book reader
GNU General Public License v2.0
168 stars 13 forks source link

Suggestion: Add lightweight alternative for Windows users experiencing the no sound issue #58

Closed bashenk closed 8 months ago

bashenk commented 8 months ago

Essentially, here's a VBS script embedded in a batch script, which can be saved as a .bat file, placed anywhere, and then used as the direct path for the audio player. E.g. image

PlayWav.bat

@if (@X)==(@Y) @end /* JScript comment
@cscript //E:JScript //nologo "%~f0" %* & @goto :EOF
@if (@X)==(@Y) @end JScript comment */
if (WScript.Arguments.Length==0) {
  WScript.Quit(0);
}
var file = WScript.Arguments.Item(0);
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (!fso.FileExists(file)) {
  WScript.Quit(1);
}
var player = new ActiveXObject("WMPlayer.OCX");
player.URL = fso.GetAbsolutePathName(file);
player.controls.play();
while (player.playState != 1) {
  WScript.Sleep(100);
}
player.close();

The only "requirement" is Windows Media Player (which can be installed natively via optionalfeatures.exe if it's not installed already). I tried using Sound API instead, but unfortunately that didn't work for me because of an error about it only supporting PCM wave files. Certainly there's other ways this could be done, but I didn't want to install or rely on any third-party dependencies.

mvf commented 8 months ago

Thanks for the suggestion! I'm all for making things more compatible, especially on Windows. Just for my understanding, this was on qolibri 2.1.4, right? The internal audio player has since been rewritten and should be working now. I only tested with .wav and .mp3 though.

If you'd like to test with qolibri-HEAD.zip, it would be much appreciated.

bashenk commented 8 months ago

image Indeed, this was on qolibri 2.1.4. However, glad to hear it's been updated! I just tested using the file you sent and that seems to be working natively.

mvf commented 8 months ago

Thanks for testing, glad it's working for you. I'mma go ahead and close this. Nice to have this as a "Plan B" though, in case issues arise with the built-in player, so thanks again!