Also, when I use Microsoft Media Player version 6.4 by itself (without
Delphi), I have no problem playing the same *.mpg files.
I thought that TMediaPlayer was just a wrapper for MS Media Player. If
so, why does it work outside of Delphi 5, but not from within Delphi 5?
Thank you in advance for any help on this.
Chris
The Format associations in Windows Media Player ( View > Options > Formats)
must be checked, otherwise TMediaPlayer refuses to play files of that type.
Instead of WMP just disabling it's own ability to load file types, depending
on whether they are checked, it removes the system-wide entries for the
format. Disabling the format's use by ANY app. Not a good idea!
You can also force it to play .mpg files, by finding the necessary entries
in System.ini and the Registry and adding them at runtime. Just turn the
Format association on and off, and note any differences. This way you don't
have to worry about whether the end-user's sytem has them checked or not -
you do it for them automatically.
g.m.
Tarvo
Chris Ford <cmit...@cmmcw.com> wrote in message
news:39782BCE...@cmmcw.com...
I was using TMediaPlayer to play mp3 files, and found out after many hours
of head scratching, that turning the mp3 associations off in Windows Media
Player 6.4 prevented TMediaPlayer from opening that file type.
g.m.
but how is it possible to write a program that plays mp3-files ? How can i
make sure that mp3 is selected to be played ?
regards, Benjamin
"the.other.g.m." <the.other.g.m.@www.scifimorgue.com> schrieb im Newsbeitrag
news:398030a3_2@dnews...
We cheat a little by using the MP3 codec that comes with Windows Media
Player, which is accessible through TMediaPlayer. Windows Media Player 6.4
or higher must be installed, and turn on "MP3 Format Sound." You can open
MP3s with TMediaPlayer - it's the same as opening a wav or midi file with
it.
You can also force mp3 format associations by having your app to make mods
to System.ini and the registry. But, as I said Windows Media Player 6.4 and
the MP3 codecs must already be on your system for this to work.
Code for Delphi 4 is below.
g.m.
========================
procedure TForm1.EnableMP3();
var winini: TIniFile;
winreg: TRegistry;
begin
if AutoEnableMP3 = False then exit;
// enables mp3 Playback, even if media Player
// cannot be set to it. Requires Windows Media Player 6.4 or higher.
//
// enable win.ini settings
winini := TIniFile.Create('c:\Windows\win.ini');
tmpstring := winini.ReadString('mci extensions','mp3','x');
if tmpstring = 'x' then
begin
// MessageDlg('Enabling mp3. Please wait while I trudge around in the
registry.', mtInformation,[mbOk], 0);
winini.WriteString('mci extensions','mp3','MPEGVideo');
winini.WriteString('mci extensions','m3u','MPEGVideo');
winini.WriteString('MCI Extensions.BAK','mp3','MPEGVideo');
winini.WriteString('MCI Extensions.BAK','m3u','MPEGVideo');
// MessageDlg('MP3 enabled!', mtInformation,[mbOk], 0);
end;
winini.free;
//
// enable mp3
winreg := TRegistry.Create;
try
winreg.RootKey := HKEY_LOCAL_MACHINE;
winreg.OpenKey('Software\Microsoft\MediaPlayer\PlayerUpgrade', False);
// get MediaPlayer version, must be 6.4 or higher
tmpstring := winreg.ReadString('PlayerVersion');
winreg.CloseKey;
if tmpstring[1] <> '6' then
begin
if MessageDlg('Windows Media Player must be upgraded to the latest
version.'+
'Click YES to visit the Microsoft site. Or, NO to exit.',
mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
begin
Form1.Visible := False;
ShellExecute(0,nil,'http://www.microsoft.com/windows/windowsmedia/',nil,nil,
0);
MessageDlg('After downloading Windows Media Player, run setup.
When it finishes installing, restart this app. Thanks.',
mtInformation, [mbOK], 0);
Application.Terminate;
end
else
MessageDlg('App will now terminate. Please remember to download
the latest version of Windows Media Player. Thanks.',
mtInformation, [mbOK], 0);
Application.Terminate;
end;
if tmpstring[3] < '4' then
begin
if MessageDlg('Windows Media Player must be upgraded to the latest
version.'+
'Click YES to visit the Microsoft site. Or, NO to exit.',
mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
begin
Form1.Visible := False;
ShellExecute(0,nil,'http://www.microsoft.com/windows/windowsmedia/',nil,nil,
0);
MessageDlg('After downloading Windows Media Player, run setup.
When it finishes installing, restart Aurika. Thanks.',
mtInformation, [mbOK], 0);
Application.Terminate;
end
else
MessageDlg('App will now terminate. Please remember to download
the latest version of Windows Media Player. Thanks.',
mtInformation, [mbOK], 0);
Application.Terminate;
end;
// enable mp3 registry settings
winreg.OpenKey('Software\Microsoft\MediaPlayer\Player\Extensions',
True);
winreg.WriteString('MP3 file (*.mp3;*.m3u)','*.mp3;*.m3u');
winreg.CloseKey;
winreg.OpenKey('Software\Microsoft\MediaPlayer\Player\Extensions\Description
s', True);
winreg.WriteString('1','Audio file
(*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3)');
winreg.WriteString('3','Movie File (MPEG)
(*.mpeg;*.mpg;*.m1v;*.mp2;*.mpa;*.mpe)');
winreg.WriteString('4','Media playlist (*.asx;*.wax;*.m3u;*.wvx)');
winreg.CloseKey;
winreg.OpenKey('Software\Microsoft\MediaPlayer\Player\Extensions\Types',
True);
winreg.WriteString('1','*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3');
winreg.WriteString('3','*.mpeg;*.mpg;*.m1v;*.mp2;*.mpa;*.mpe');
winreg.WriteString('4','*.asx;*.wax;*.m3u;*.wvx');
winreg.CloseKey;
// get
finally
winreg.Free;
end;
end;