AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Wave abspielen in C#

Ein Thema von Ultimator · begonnen am 22. Feb 2005
Antwort Antwort
Benutzerbild von Ultimator
Ultimator

Registriert seit: 17. Feb 2004
Ort: Coburg
1.860 Beiträge
 
FreePascal / Lazarus
 
#1

Wave abspielen in C#

  Alt 22. Feb 2005, 17:23
So, hab wieder mal ne Frage

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
Julian J. Pracht
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:08 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