Read-only archive of the All About Symbian forum (2001–2013) · About this archive

HOWTO: Play sound on a 9210 with MediaServer.OPX ???

30 replies · 7,406 views · Started 16 July 2003

Help,

can anybody post an example here for
playing (.WAV)-Files on an 9210 with OPL ?

(I think the MediaServer.OPX is needed).

Regards,

Luzie

Luzie,

I've used the code below to successfully play a wave file with OPL. Try it and let me know.

Regards

DECLARE EXTERNAL
INCLUDE "MediaServerOpx.oxh"

EXTERNAL tFilePlayerSimple
EXTERNAL tFilePlayerStop

Rem change this to where your wav file is
CONST KWAVFilename$="d\Documents\Tones\arrow.wav"

CONST KPriority&=KMdaPriorityNormal&
CONST KPreference&=KMediaSMdaPriorityPrefTimeQual&

PROC Main
GLOBAL gStatus&
tFilePlayerSimple
tFilePlayerStop
PRINT "Test code complete." PRINT "Press any key" GET
ENDP

PROC tFilePlayerSimple
EXTERNAL gStatus&
LOCAL priority&,preference&
IF NOT EXIST(KWAVFilename$)
ALERT(KWAVFilename$,"not found, test abandoned."😉
RETURN
ENDIF
priority&=0
preference&=KPreference&
CreateFilePlayerSimpleA(KWAVFilename$,gStatus&amp😉
IOWAITSTAT32 gStatus&
PRINT " PlayFileA",KWAVFilename$
PlayFileA(gStatus&amp😉
IOWAITSTAT32 gStatus&
CloseFilePlayer
PRINT
ENDP

PROC tFilePlayerStop
EXTERNAL gStatus&
CreateFilePlayerA(KWAVFilename$,KPriority&,KPreference&,gStatus&amp😉
IOWAITSTAT32 gStatus&
PlayFileA(gStatus&amp😉
StopFile
CloseFilePlayer
ENDP

Terminator wrote:Luzie,

I've used the code below to successfully play a wave file with OPL. Try it and let me know.

Regards

DECLARE EXTERNAL
INCLUDE "MediaServerOpx.oxh"

EXTERNAL tFilePlayerSimple
EXTERNAL tFilePlayerStop

Rem change this to where your wav file is
CONST KWAVFilename$="d\Documents\Tones\arrow.wav"

CONST KPriority&=KMdaPriorityNormal&
CONST KPreference&=KMediaSMdaPriorityPrefTimeQual&

PROC Main
GLOBAL gStatus&
tFilePlayerSimple
tFilePlayerStop
PRINT "Test code complete." PRINT "Press any key" GET
ENDP

PROC tFilePlayerSimple
EXTERNAL gStatus&
LOCAL priority&,preference&
IF NOT EXIST(KWAVFilename$)
ALERT(KWAVFilename$,"not found, test abandoned."😉
RETURN
ENDIF
priority&=0
preference&=KPreference&
CreateFilePlayerSimpleA(KWAVFilename$,gStatus&amp😉
IOWAITSTAT32 gStatus&
PRINT " PlayFileA",KWAVFilename$
PlayFileA(gStatus&amp😉
IOWAITSTAT32 gStatus&
CloseFilePlayer
PRINT
ENDP

PROC tFilePlayerStop
EXTERNAL gStatus&
CreateFilePlayerA(KWAVFilename$,KPriority&,KPreference&,gStatus&amp😉
IOWAITSTAT32 gStatus&
PlayFileA(gStatus&amp😉
StopFile
CloseFilePlayer
ENDP

I have used this code, but my 9210i has many problems with it ! Does Anybody have a solution now for playing sounds ????

Terminator wrote:Luzie,

I've used the code below to successfully play a wave file with OPL. Try it and let me know.

Regards

DECLARE EXTERNAL
INCLUDE "MediaServerOpx.oxh"

EXTERNAL tFilePlayerSimple
EXTERNAL tFilePlayerStop

Rem change this to where your wav file is
CONST KWAVFilename$="d\Documents\Tones\arrow.wav"

CONST KPriority&=KMdaPriorityNormal&
CONST KPreference&=KMediaSMdaPriorityPrefTimeQual&

PROC Main
GLOBAL gStatus&
tFilePlayerSimple
tFilePlayerStop
PRINT "Test code complete." PRINT "Press any key" GET
ENDP

PROC tFilePlayerSimple
EXTERNAL gStatus&
LOCAL priority&,preference&
IF NOT EXIST(KWAVFilename$)
ALERT(KWAVFilename$,"not found, test abandoned."😉
RETURN
ENDIF
priority&=0
preference&=KPreference&
CreateFilePlayerSimpleA(KWAVFilename$,gStatus&amp😉
IOWAITSTAT32 gStatus&
PRINT " PlayFileA",KWAVFilename$
PlayFileA(gStatus&amp😉
IOWAITSTAT32 gStatus&
CloseFilePlayer
PRINT
ENDP

PROC tFilePlayerStop
EXTERNAL gStatus&
CreateFilePlayerA(KWAVFilename$,KPriority&,KPreference&,gStatus&amp😉
IOWAITSTAT32 gStatus&
PlayFileA(gStatus&amp😉
StopFile
CloseFilePlayer
ENDP

😎 (A happy blind hacker!)
Good work, this worked for me (after I patched up for missing "colon" chars, and removed spurious "amp" and semi-colons, which the board must have mangled.

If I got lucky, I've attached the tidied code as a plain text file, which you can view with Notepad, and import into the 9210 emulator "Program" app with "File|More|Import text..." (choose "Show all files" from CBA!).

Multo Grazie!

Terminator wrote:Luzie,

I've used the code below to successfully play a wave file with OPL. Try it and let me know.

Regards

DECLARE EXTERNAL
INCLUDE "MediaServerOpx.oxh"

EXTERNAL tFilePlayerSimple
EXTERNAL tFilePlayerStop

Rem change this to where your wav file is
CONST KWAVFilename$="d\Documents\Tones\arrow.wav"

CONST KPriority&=KMdaPriorityNormal&
CONST KPreference&=KMediaSMdaPriorityPrefTimeQual&

PROC Main
GLOBAL gStatus&
tFilePlayerSimple
tFilePlayerStop
PRINT "Test code complete." PRINT "Press any key" GET
ENDP

PROC tFilePlayerSimple
EXTERNAL gStatus&
LOCAL priority&,preference&
IF NOT EXIST(KWAVFilename$)
ALERT(KWAVFilename$,"not found, test abandoned."😉
RETURN
ENDIF
priority&=0
preference&=KPreference&
CreateFilePlayerSimpleA(KWAVFilename$,gStatus&amp😉
IOWAITSTAT32 gStatus&
PRINT " PlayFileA",KWAVFilename$
PlayFileA(gStatus&amp😉
IOWAITSTAT32 gStatus&
CloseFilePlayer
PRINT
ENDP

PROC tFilePlayerStop
EXTERNAL gStatus&
CreateFilePlayerA(KWAVFilename$,KPriority&,KPreference&,gStatus&amp😉
IOWAITSTAT32 gStatus&
PlayFileA(gStatus&amp😉
StopFile
CloseFilePlayer
ENDP

Attachments: Document.txt (2 KB)

This means that there are non default line breaks in the code you copied and pasted into the OPL editor.

If you configure the editor to display line breaks you can see where the correct line breaks are missing. Line breaks are displayed as a horizontally mirrored P. Just remove the incorrect line breaks with backspace and hit enter to replace it with a real linebreak.

Maybe the text was saved as Unix (LF) instead of DOS (CR/LF) text, so there is not CR to tell the OPL editor that the lines end.

I have just saved the attached file (as DOS text), then used "File/More/Import text... Shift+Ctrl+I" within the OPL Editor.

Ok. I pressed enter after every line.
Now it says after Translate: "Not found" (in finnish:"Ei l�ydy"😉 And goes to line: INCLUDE "MediaServerOpx.oxh"

Do I need to install that from somewhere?

I'm just starting with OPL and am using this code - I sorted out the formatting errors, it translates fine and runs quite happily, but finishes in a couple of seconds without playing anything ! It finds that file OK, but nothing - any clues ?

No work!
Record too large!

I downloaded that file to my PC. Opened it. Copyed the text to a mail. Sent it to my 9210i. Openend it there. Copied text. Opened TextEd and Pasted text. Translated and Record to large.

I put an empty line between every line and now after I press Translate it says: Not found! and the cursor goes to that line: INCLUDE "MediaServerOpx.oxh"

And why my BEEP 5,300 and BEEP 100,300 makes the same sound for about 8 seconds? And the sound is quite awfull... after about 3 seconds the sound gets a little bit louder.

Now I put BEEP -1,500 and it won't shut up at all...

raksutiikeri wrote:No work!
Record too large!

I downloaded that file to my PC. Opened it. Copyed the text to a mail. Sent it to my 9210i. Openend it there. Copied text. Opened TextEd and Pasted text. Translated and Record to large.


Digging the net I found this old topic;
for people which will come even later... I suppose the problem is that users did past the code into their devices in place of IMPORTING it with OPL import function! Although, I didn't try it by nyself yet...

Anyway, I have a further question; which formats are supported by OPL? Just WAV?

Does anyone have a solution for this: When I try to translate the code, the application warns: "Not found." Where can I get MediaServerOPX.oxh?

Identity wrote:Does anyone have a solution for this: When I try to translate the code, the application warns: "Not found." Where can I get MediaServerOPX.oxh?

There is a bug in the SIS file for UIQ development, so not all of the OPX/OXH files are copied in the right place on the phone.
Look inside the OPL Developer directory structure, and find needed file in folder rel\dev\examplesrc\target\system\opl ; here you'll aslso find CONST.OPH which, if I remember correctly, also is NOT copied to the phone.

I'm not sure, but I think you'll also need corresponding OPX file, but I can only find Mediaserveropx.opx inside WINSCW folders, so probably they are emulator versions....

Let us know if you'll success in playing WAV files! Which platform are you coding for?

I�m coding for Crystal a.k.a Series 80 (more precisely Nokia 9210). I can�t get the code work because of the MediaServerOPX.oxh, because I don�t have one. I have only MediaServerOPX.opx in the folder D:\System\OPX\ on the phone.

Identity wrote:I�m coding for Crystal a.k.a Series 80 (more precisely Nokia 9210). I can�t get the code work because of the MediaServerOPX.oxh, because I don�t have one. I have only MediaServerOPX.opx in the folder D:\System\OPX\ on the phone.

Did you try the one inside rel\dev\examplesrc\target\system\opl folder?

This is a correct code (for Series 80) to play a wav file:

DECLARE EXTERNAL
INCLUDE "MediaServerOpx.oxh"

EXTERNAL tFilePlayerSimple:
EXTERNAL tFilePlayerStop:

REM change this to where your wav file is
CONST fileName$="d:\?\?.wav"

CONST KPriority&=KMdaPriorityNormal&
CONST KPreference&=KMediaSMdaPriorityPrefTimeQual&

PROC main:
GLOBAL soundStatus&
tFilePlayerSimple:
tFilePlayerStop:
PRINT "Test code complete."
PRINT "Press any key."
GET
ENDP

PROC tFilePlayerSimple:
EXTERNAL soundStatus&
LOCAL priority&,preference&
IF NOT EXIST(fileName$)
ALERT(fileName$,"not found, test abandoned."😉
RETURN
ENDIF
priority&=0
preference&=KPreference&
CreateFilePlayerSimpleA😞fileName$,soundStatus&😉
IOWAITSTAT32 soundStatus&
PRINT "PlayFileA",fileName$
PlayFileA😞soundStatus&😉
IOWAITSTAT32 soundStatus&
CloseFilePlayer:
ENDP

PROC tFilePlayerStop:
EXTERNAL soundStatus&
CreateFilePlayerA😞fileName$,KPriority&,KPreference&,soundStatus&😉
IOWAITSTAT32 soundStatus&
PlayFileA😞soundStatus&😉
StopFile:
CloseFilePlayer:
ENDP

Tell me if there�s bug/bugs in the code.

Identity wrote:This is a correct code (for Series 80) to play a wav file:

Congratulations & thanks, your source works fine on my UIQ phones; only a couple of errors found:


PlayFileA😞soundStatus$)
IOWAITSTAT32 soundStatus$

You must replace both "$" with "&".

And don't forget to use (code)(/code) tags when you post your source, else if it contains "strange characters" like these:


(drive c😊

it will become a funny

(drive c😊

😉

P.S.
There is also a missing " in the line containing the name of WAV file.

A couple of typos, sorry 🙄

Cassioli, I think we need an .opx for that. But I�m just 16-year-old and started programming OPL 1� months ago, so don�t look at me 😃

Identity wrote:A couple of typos, sorry 🙄

Cassioli, I think we need an .opx for that. But I�m just 16-year-old and started programming OPL 1� months ago, so don�t look at me 😃

16 years? Ok, you're on holydays since 2 months , haven't you yet learnt how to program Symbian phones in C++? 🙄 😉 I really need some new OPXs... :frown:

[edit: deleted a stupid question...]

cassioli wrote:16 years? Ok, you're on holydays since 2 months , haven't you yet learnt how to program Symbian phones in C++? 🙄 😉 I really need some new OPXs... :frown:

[edit: deleted a stupid question...]

I�m starting from this very easy language, OPL and when I know enough about variables, strings, blaah, blaah, blaah -things, I move into the deep, crazy, hell-hard world of C++. So it�s coming up, don�t know yet when 😊

OT: School starts tomorrow!!! Noooooooo!!!