Autor Beitrag
hBc | AgentSmith
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 14.03.05 20:30 
hallo erstaml.

Diesen Thread gibt/gab es bestimmt schon x1000 mal aber ich bin zu faul zum suchen :D .

Ich möchte ganz simple ein Musikfile abspielen lassen wenn das Programm startet.
Ich habe bei OnCreate mit schellexecute das lied abspielen lassen, nur war das nicht mein ziel.
ich wollte nicht, dass sich dann Winamp öffnet, sondern Delphi das Lied abspielt.
Ist das irgendwie möglich?? Sorcecode beispiele erwünscht :o .

ähm...noch dazu: bitte nichz allzuschwierig....hab noch nicht allzuviel Ahnung :lol:




Danke schon mal im Vorraus....mfg hBc | AgentSmith
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 14.03.05 20:38 
Dann bin ich zu faul zum geben einer nützlichen Antwort!

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Stefan-W
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 14.03.05 20:55 
Warum nutzt du nicht die Suchfunktion du brauchs do nur paar begriffe von deinem Text eingeben...

zb.: "Sound", "Abspielen" oder so ganz einfach und schon hast du deine lösung
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Mo 14.03.05 21:13 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
uses 
  ..., MMSystem;

procedure PlayWav(FileName: string);
begin
  if not FileExists(FileName) then Exit;

  try
    sndPlaySound(PChar(FileName), SND_ASYNC);
  except end;
end;


Zu der Konstante SND_ASYNC sannst du etwas in der API Hilfe nachlesen. Mit der richtigen Konstante kannst du auch ein Loop laufen lassen.

_________________
Popov
Calyptus
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: Di 15.03.05 19:47 
kann man das auch irgendwie mit mp3/ogg machen?

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Di 15.03.05 19:55 
user profile iconCalyptus hat folgendes geschrieben:
kann man das auch irgendwie mit mp3/ogg machen?


TMediaplayer sofern der erforderliche Codec installiert ist. Bei MP3 kein Problem, bei OGG wär ich eher vorsichtig

AXMD
beshig
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 110
Erhaltene Danke: 1

WIN 2000, WIN XP, WIN 2003, Debian Linux
Delphi 7 Personal, Delphi 2005 Personal
BeitragVerfasst: Di 15.03.05 23:35 
@hBc | AgentSmith: Sei froh, dass du so nen Satz wegen zu Faul zum suchen nicht in meinem Forum gepostet hast ! Denn es gibt Foren, wo es noch weniger gern gesehen wird, wie faul doch manche Menschen zum suchen sind !
Ps, gute Hilfe findest du hier.

_________________
Was ist ein Moderatorenteam in einem recht bekannten Programmierer-Forum ? Viele Meinungen, eine zählt - Mehr ist ja auch nicht notwendig...
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.03.05 07:52 
Titel: TMediaoplayer
Ziehe die Komponente Mediaplayer aufs formular und stelle bei "Filter" die entsprechenden Dateiendungen ein. (mp3 funzt bei mir auch!) Nun schreibst du bei filename den Dateipfad rein und schreibst bei formcreate:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
if fileexists(mediaplayer1.filename) then
begin
with mediaplayer 1 do begin
open;
play;
end;
end
else begin
showmessage('Die angegebene Datei wurde nicht gefunden.');
end;


noch fragen?

mfg koller

Moderiert von user profile iconAXMD: Delphi-Tags hinzugefügt.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 16.03.05 07:54 
@Koller: verwende bitte das nächste Mal Delphitags, wenn du Quelltext postet. Einrückungen wären auch nicht schlecht - und das "1" gehört (ohne Abstand) direkt neben "Mediaplayer"

AXMD
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.03.05 08:08 
Titel: Delphitags
Was war mit "Delphitags" gemeint? Bei dem anderen haste recht!!!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 16.03.05 08:16 
und wenn du auch ogg abspielen möchtes hilft dir fmod weiter:
(erst bei www.fmod.de runterladen)
beispiel:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
uses ....fmod,fmoderrors,fmodtypes;
const
  Load  = 0;
  Play  = 1;
  Stop  = 2;
  Pause = 3;

type
  TSong = record
    Module: PFMusicModule;
    Stream: PFSoundStream;
    Channel: Integer;
    FileName:String;
  end;

constructor TFmod.Create(Handle:Cardinal);
begin
  if FMOD_VERSION > FSOUND_GetVersion then begin
    ShowMessage(PChar(Format('API version %3.2f is newer than DLL version %3.2f', [FMOD_VERSION, FSOUND_GetVersion])));
    exit;
  end;

  { Initialize FSOUND }
  try
    if not FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND) then
      raise Exception.Create('FSOUND_SetOutput failed');
    if not FSOUND_SetDriver(0) then
      raise Exception.Create('FSOUND_SetDriver failed');
    if not FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT) then
      raise Exception.Create('FSOUND_SetMixer failed');
    if not FSOUND_SetHWND(Handle) then
      raise Exception.Create('FSOUND_SetHWND failed');
  except
    ShowMessage(FMOD_ErrorString(FSOUND_GetError));
    raise;
  end;

  if not FSOUND_Init(22050, 128, FSOUND_Init_GlobalFocus) then begin
    Showmessage(FMOD_ErrorString(FSOUND_GetError));
    exit;
  end;
  ClearMusic;
end;

procedure TFmod.LoadMusic(FileName:TFileName;AutoPlay:Boolean = True);
begin
  ClearMusic;
  StatusMusic:=Load;
  Music.FileName:=FileName;
  
  if IsLoadMusic = True then begin
    StopMusic;
  end;

  Music.Module := FMUSIC_LoadSong(PChar(Music.FileName));
  FMUSIC_SetLooping(Music.Module,False);

  if Music.Module = nil then
    Music.Stream := FSOUND_Stream_Open(PChar(Music.FileName), FSOUND_NORMAL, 0,0);

  if (Music.Module = nil) and (Music.Stream = nil) then begin
    Showmessage(FMOD_ErrorString(FSOUND_GetError));
    exit;
  end;

  if Music.Module <> nil then  FMUSIC_SetMasterVolume(Music.Module, 255);

  if AutoPlay = True then PlayMusic;
end;

procedure TFmod.PlayMusic;
begin
  // wenn nicht geladen, dann rufe exit
  if isLoadMusic = False then exit;

  // wenn geladen dann spiele diese datei ab
  if Music.Module <> nil then begin
    FMUSIC_PlaySong(Music.Module);
    if Music.Module = nil then
      ShowmEssage(FMOD_ErrorString(FSOUND_GetError));
  end
  else begin
    if Music.Stream <> nil then begin
      Music.Channel := FSOUND_Stream_Play(FSOUND_FREE, Music.Stream);

      if Music.Channel = -1 then begin
        ShowMessage(FMOD_ErrorString(FSOUND_GetError));
      end
    end;
  end;
  StatusMusic:=Play;

end;

damit kannst du eine datei gleichzeitig abspielen(aber sie wiederholt sich nicht, wenn du das auch möchtes muss etwas mehr aufwand getrieben werden *G*)
bin gerade dabei eien unit zu schreiben die ist eigetnlich sogut wie fertig es fehlen noch ein paar sachen bei den FMuisc_ funktionen bzw. bei dem midi format *G*....

wenn alles funktioniert kannst du jetzt folgende dateitypen abspielen

MOD,S3M,XM,IT,MID,RMI,SGT
WAV,MP2,MP3,OGG,WMA,ASF

_________________
MFG
Michael Springwald, "kann kein englisch...."