[Solved] Macro to play MP3 audio file with LibreOffice

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
csang
Posts: 4
Joined: Fri Sep 02, 2022 10:26 am

[Solved] Macro to play MP3 audio file with LibreOffice

Post by csang »

 Edit: Split from Calc Macro to play an MP3 Audio File because your situation (LibreOffice) is different so you need your own topic. If you had the same environment you could use the same solution. Please do not post in another's topic unless you are helping to solve their problem for them. 

Hello, I was using Musikai's code and it worked on my OpenOffice 4.1.13 under windows 10.
But due to certain bug of OO, I tried to switch to Libreoffice 7.4
The code then runs and play sound once and stop playing when called again.
Noticed the code never end execution. Stuck at the while oPlayer1. Isplaying() doevent part never exit loop.

Anyone know what's wrong?
Last edited by Hagar Delest on Sun Sep 04, 2022 11:19 am, edited 1 time in total.
Reason: Tagged [Solved].
OpenOffice 4.1 on Windows 10
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro to play MP3 audio file with LibreOffice

Post by JeJe »

You could replace the loop with a wait statement.
getduration * 1000 - seems to wait too long for me - you may have to play around with the 1000 figure.

Code: Select all

       oPlayer1.setPlayBackLoop( 0 )
            oPlayer1.start(0)
     		wait  oPlayer1.getduration * 1000 
           oPlayer1 = nothing
           oSounMgr = nothing
     
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
csang
Posts: 4
Joined: Fri Sep 02, 2022 10:26 am

Re: Macro to play MP3 audio file with LibreOffice

Post by csang »

Perfect! Thanks 🙏
I'm using an old (aka) slow notebook, duration * 500 seems to work fine.
OpenOffice 4.1 on Windows 10
Post Reply