Q.) I am writing a program using Delphi prism. The goal is to be able run on windows and linux (mono) from the same project. So, at this point I need to have a way of playing a sound file for windows and linux(mono) without having to import winmm.dll or microsoft.visualbasic.dll.
Since I need this to work on mono also, I don't want to use visualbasic.dll. In the past, it gave me all kinds of issues.
Are there ways to play sound file without using these dll files?
UPDATE
No matter how the soundplayer is instantiated and used, it always works fine under windows OS, whereas on Linux under mono it sometimes plays and other times it just won't play at all.
First Version:
Since I need this to work on mono also, I don't want to use visualbasic.dll. In the past, it gave me all kinds of issues.
Are there ways to play sound file without using these dll files?
UPDATE
No matter how the soundplayer is instantiated and used, it always works fine under windows OS, whereas on Linux under mono it sometimes plays and other times it just won't play at all.
First Version:
var thesound := new SoundPlayer;
if Environment.OSVersion.Platform = Environment.OSVersion.Platform.Unix then
thesound.SoundLocation := '/sounds/Alarms.wav'
else
thesound.SoundLocation:='\sounds\Alarms.wav';
thesound.Load;
thesound.PlayLooping;
Second Versionvar sp := new SoundPlayer(new FileStream("/sounds/Alarms.wav", FileMode.Open, FileAccess.Read, FileShare.Read));
sp.PlayLooping;
A.) You can useSystem.Media.SoundPlayer
. This is implemented by Mono.
No comments:
Post a Comment