PHP beginner |
|
Hallo allemaal,
Ik vraag me af hoe ik met Csharp.net geluidjes kan afspelen. Nou zag ik deze topic, maar bij mij werkt het niet. Mijn code is momenteel als volgt:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.Runtime.InteropServices; //dll import mogelijk maken
namespace defaultSounds
{
public partial class Form1 : Form
{
string soundCommand;
// nodig voor de muziek
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
public Form1()
{
InitializeComponent();
}
private void playMusic(string soundFile)
{
if (soundCommand == "play MediaFile")
{
soundCommand = "close MediaFile";
mciSendString(soundCommand, null, 0, IntPtr.Zero);
}
soundCommand = "open \""+ soundFile +"\" type mpegvideo alias MediaFile";
mciSendString(soundCommand, null, 0, IntPtr.Zero);
soundCommand = "play MediaFile";
mciSendString(soundCommand, null, 0, IntPtr.Zero);
}
private void button1_Click(object sender, EventArgs e)
{
playMusic("type.wma");
}
}
}
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Windows; using System.Runtime.InteropServices; //dll import mogelijk maken namespace defaultSounds { public partial class Form1 : Form { string soundCommand; // nodig voor de muziek [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); public Form1() { InitializeComponent(); } private void playMusic(string soundFile) { if (soundCommand == "play MediaFile") { soundCommand = "close MediaFile"; mciSendString(soundCommand, null, 0, IntPtr.Zero); } soundCommand = "open \""+ soundFile +"\" type mpegvideo alias MediaFile"; mciSendString(soundCommand, null, 0, IntPtr.Zero); soundCommand = "play MediaFile"; mciSendString(soundCommand, null, 0, IntPtr.Zero); } private void button1_Click(object sender, EventArgs e) { playMusic("type.wma"); } } }
Bedankt alvast voor jullie hulp!
Martijn
|