Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   C# Wave abspielen in C# (https://www.delphipraxis.net/40884-wave-abspielen-c.html)

Ultimator 22. Feb 2005 17:23


Wave abspielen in C#
 
So, hab wieder mal ne Frage :mrgreen:

Und zwar versuche ich, mittels einem bei www.mycsharp.de im Forum gefundenen Code eine Wave-Datei abzuspielen.

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:
#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);
        }
    }

    }
}
Falls jemand noch andere Anmerkungen zum Code hat, gerne her damit, ich fang gerade erst mit C# an ;-)


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz