Skip to Content
Author's profile photo Michael Keller

music please

One of the things I missed a few times in ABAP was playing a sound. Not that it would be very important in my daily work but it’s one way to give the user a feedback. Think of a loud “tada” when selection has ended, ALV is displayed and the user needs to be woken up … 😉

Thanks to Enno Wulff’s contribution on I <heart> ABAP, I remembered using ABAP and OLE in several projects to access data from Excel and Outlook. But somehow I never checked wether Windows Media Player can be controlled by OLE. The answer is “yes”, here is the documentation (check “Object Model Reference“).

I wrote a little demo which you can get from GitHub. My goal was to play/stop music file “C:\Windows\Media\town.mid” when pushbutton is pressed.Therefore just two pushbuttons in the demo:

With the Microsoft documentation I think it’s easy to enhance my class so you can increase volume.

As preperation you have to register Windows Media Player in transaction SOLE as an OLE application once. You can choose your own name for the OLE application. I used “WMP”. Furthermore a ClassID is needed which I took from the Microsoft Answers Forum. It’s {6BF52A52-394A-11d3-B153-00C04F79FAA6}. On my Windows 7 and Windows 10 installation that worked fine.

 

Have fun trying it and see you soon

Michael

 

 

 

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Raymond Giuseppi
      Raymond Giuseppi

      Your next step could be adding 'voice' to your program (with SAPI.SpVoice)

      Author's profile photo Enno Wulff
      Enno Wulff

      Something like that:

      https://www.tricktresor.de/blog/speak/

      ? 😉

      Author's profile photo Raymond Giuseppi
      Raymond Giuseppi

      Yes, or Text to Speech ,SAP system will speak to you !!!! in blog section of forum.

      Author's profile photo Michael Keller
      Michael Keller
      Blog Post Author

      Great idea. So I don't have to buy radioplay. Now I can listen to longtext of error messages. Just a joke 😉 That's another interesting technology. Thanks for the note.

      Author's profile photo Peter Inotai
      Peter Inotai

      There was something similar from Thomas Jung a long time ago:

      https://blogs.sap.com/2005/05/11/using-classic-activex-controls-in-the-abap-control-framework/

      Author's profile photo Michael Keller
      Michael Keller
      Blog Post Author

      I think Stefan Schnell did something with ActiveX/Windows Media Player, too. But I cannot find the blog link at the moment 🙁

      Author's profile photo Stefan Schnell
      Stefan Schnell

      Hello Michael,

      your can find my blog here.

      Best regards
      Stefan

      Author's profile photo Enno Wulff
      Enno Wulff

      It's a pity, Merlin has gone... ;(

      He could also be programmed in SAP via OLE.

      Didn't work very well, but it worked.

      Author's profile photo Michael Keller
      Michael Keller
      Blog Post Author

      Merlin was a nice agent. That would have been fun to control his movements via OLE 🙂

       

       

      Author's profile photo Enno Wulff
      Enno Wulff

      Yes, but also annoying.

      I tried here to  guide a user through a "form" and enter data. Merlin reacted not very good and fast on field changes or keyboard input.

      Nowadays with more experience with gui controls it might be nice to let Merlin pop up when the user clicks on tree nodes or tab...