Forum » Programiranje » C# zvok
C# zvok
Loaded ::
lp
rad bi predvajal kratke mp3 datoteke na nek event. stvar deluje, ko se event prvič sproži, potem pa ne več.
razred zvok
[code]
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
namespace GlobalHookDemo
{
class Zvok
{
private string _command;
private bool isOpen;
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
public Zvok() { }
public void Close()
{
_command = "close MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = false;
}
public void Open(string sFileName)
{
_command = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = true;
}
public void Play(bool loop)
{
if(isOpen)
{
_command = "play MediaFile";
if (loop)
_command += " REPEAT";
mciSendString(_command, null, 0, IntPtr.Zero);
}
}
}
}
[/code]
tu pa še kako kličem.
[code]
zvok.Open("C:/krneki.mp3");
zvok.Play(false);
[/code]
rad bi predvajal kratke mp3 datoteke na nek event. stvar deluje, ko se event prvič sproži, potem pa ne več.
razred zvok
[code]
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
namespace GlobalHookDemo
{
class Zvok
{
private string _command;
private bool isOpen;
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
public Zvok() { }
public void Close()
{
_command = "close MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = false;
}
public void Open(string sFileName)
{
_command = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = true;
}
public void Play(bool loop)
{
if(isOpen)
{
_command = "play MediaFile";
if (loop)
_command += " REPEAT";
mciSendString(_command, null, 0, IntPtr.Zero);
}
}
}
}
[/code]
tu pa še kako kličem.
[code]
zvok.Open("C:/krneki.mp3");
zvok.Play(false);
[/code]
Loadeed
Loaded ::
Če dam tole
zvok.Open("C:/krneki.mp3"); zvok.Play(false); zvok.Close();mi ga sploh ne predvaja...
Loadeed
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [C#] Prehajanje na low levelOddelek: Programiranje | 1313 (1069) | krneki0001 |
» | [C#] pixel scan z ThreadOddelek: Programiranje | 1169 (951) | perooo25 |
» | kako narediti program ki bere drugi programOddelek: Programiranje | 5735 (4048) | imagodei |
» | video v c#Oddelek: Programiranje | 1535 (1075) | boss-tech |
» | Vb6Oddelek: Programiranje | 1327 (1190) | StratOS |