![]() |
Wave abspielen in C#
So, hab wieder mal ne Frage :mrgreen:
Und zwar versuche ich, mittels einem bei ![]() Das funktioniert scheinbar auch wunderbar, allerdings hört der Sound nach ~10 Sekunden aprupt auf. Eigentlich kann ich mir nicht vorstellen, dass ich bei diesem recht kleinen Code sehr viel falsch gemacht hab, aber schauts euch bitte trotzdem mal an ;-)
Code:
Falls jemand noch andere Anmerkungen zum Code hat, gerne her damit, ich fang gerade erst mit C# an ;-)
#region Using directives
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; #endregion namespace WindowsApplication1 { partial class Form1 : Form { [DllImport("winmm.dll")] public static extern long PlaySound(String lpszFileName, long hModule, long dwFlags); const int SND_SYNC = 0x0000; //Synchron abspielen const int SND_ASYNC = 0x0001; //Asynchron abspielen const int SND_LOOP = 0x0008; //Solange bis zum nächsten PlaySound abspielen public void Abspielen(string Datei) { PlaySound(Datei, 0, SND_ASYNC); //Application.DoEvents(); <- Hat auch nix gebracht } public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { if (openFileDialog1.FileName != "") { Abspielen(openFileDialog1.FileName); } } } } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:10 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz