Autor Beitrag
The...
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 02:48 
Hi,
also ich möchte beim drücken eines buttons einen bestimmten sound abspielen...aller dings nich ein sound aus einem bestimmten verzeichnis, sodern der sound muss in der anwendung 'gespeichert sein'!
Also das abspielen von Sounds habe ich hin bekommen... (das reicht aber nicht)

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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,mmsystem, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
 sndPlaySound(PChar('C:\online'),SND_ASYNC);
end;

end.



Okey, dann schon mal danke!

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 03.02.05 03:29 
Kopiere die Sounddatei (z.B. MySong.wav) in dein Projektverzeichnis. Erstelle im Projektverzeichnis eine neue Textdatei (z.B. MySong.rc). Inhalt von MySong.rc:
ausblenden Quelltext
1:
MySong    WAVE    "MySong.wav"					

In der Delphi Menüleiste wählst du: Projekt--->Dem Projekt hinzufügen--->
In dem Öffnen Dialog wählst du als Dateityp "Resourcen-Datei (*.rc) und wählst dann die Datei "MySong.rc" aus.

In deinem ButtonClick Ereignis trägst du dann folgendes ein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button1Click(Sender: TObject);
var
  ResStream: TResourceStream;
begin

  ResStream := TResourceStream.Create(0'MySong''WAVE');
  try
    PlaySound(ResStream.Memory, 0, SND_MEMORY or SND_SYNC);
  finally
    ResStream.Free;
  end;

end;


Speichern. Kompilieren. Starten und den Klängen lauschen...



Edit: // Die Funktion PlaySound ist wie sndPlaySound in der Unit MMSystem deklariert.

_________________
Ciao, Sprint.
The... Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 18:22 
erstmal danke!

...aber ich habe das nun so gemacht... baer beim hinzu fügen zeigt er bei mir die .rc Datei nicht an ob wohl ich sie selbst ertellt habe... und wenn ich sie denn mit 'alle Datein ' auswähle geht es nicht???

Bitte nochmal um hilfe!
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 03.02.05 18:40 
Kann es sein, das deine Datei als Endung txt hat? Also z.B. so MyResource.rc.txt

_________________
Ciao, Sprint.
The... Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 18:50 
ja... aber wie bekomme ich das weg ???
also ich habe ein Textdokument erstellt, und dann in Blip.rc umbend !


Zuletzt bearbeitet von The... am Do 03.02.05 18:58, insgesamt 1-mal bearbeitet
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 03.02.05 18:54 
The... hat folgendes geschrieben:
ja... aber wie bekomme ich das weg ???

Datei umbenennen. Arbeitest du das erstemal mit Windows?

_________________
Ciao, Sprint.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 03.02.05 18:59 
Du kannst die Resourcendatei auch manuell kompilieren. Dazu eine neue Batchdatei anlegen (z.B. BuildRes.bat) und in deinem Projektverzeichnis speichern.
ausblenden Quelltext
1:
2:
3:
@ECHO OFF
"C:\Programme\Borland\Delphi5\Bin\brcc32.exe" MySong.rc
PAUSE

Die 5 in Delphi5 durch deine Versionsnummer ersetzen. Batchdatei starten.

In Delphi trägst du dann folgende Zeile zu deinem SourceCode hinzu:
ausblenden Delphi-Quelltext
1:
{$R MySong.res}					

_________________
Ciao, Sprint.
The... Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 19:02 
jaja... lol so umbenad habe ich sie ja auch :P :roll: :!: !!!!
aber das geht nicht.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 03.02.05 19:11 
Ich habe das unter Delphi 5 Professional, Delphi 6 & 7 Personal getestet. Komisch. Das du das nicht hinbekommst.


Edit: //
Zitat:
aber das geht nicht.

Was geht denn nicht?

_________________
Ciao, Sprint.
The... Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 19:38 
...man was ist blos los mit mir...schei** !

Also ich habe die .wav datei in das verzeichnis kopiert und dann ein textdukoment erstellt! In das Text duko geschriben:

ausblenden Quelltext
1:
Blip wave "Blip.wav"					



genant habe ich es Blip.rc

dann noch den code eingegeben (in Delphi)

Problem: also da steht dan nebn unit1 Blip.rc.txt !!!
Das txt solt da nicht sein!
Wir dir aber auserhalb von Delphi nicht angezeigt!


was nun... warum bekomme ich das nicht hin??? :cry:
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 03.02.05 19:49 
Warum benennts du die Datei nicht um?

_________________
Ciao, Sprint.
The... Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 19:56 
Okey also irgendetwas mach ich da kommplet faltsch... also ich bin auf c:/programmen/bordland/Dlphi/Projekt... dann in hauptverzeichnis bin ich auf rechte maus taste-> neu-> Textdukument, das habe ich blip.rc getauft.. und da steht auch kein text mehr hinter!
aber in delphi steht da dann immer blip.rc.txt !!!
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 03.02.05 19:59 
1.) im explorer unter extras, ordneroptionen, ansicht "dateiendung bei bekannten typen ausblenden" deaktivieren
2.) bei notepad vor dem speichern unten als dateityp "Alle Dateien (*.*)" auswählen
The... Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 03.02.05 20:12 
dachte ich auch schon...hat aber nichst gebracht haeb es nun anders geamcht...DANKE @all