This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Showing posts with label c# code for notepad. Show all posts
Showing posts with label c# code for notepad. Show all posts

Tuesday, November 11, 2008

How to play multimedia files (wav, mp3, wma.) using MCI

Play multimedia files using MCI and C#

Multimedia can enhance the graphical user interface and the presentation of your application. It is very important that you application is visual appealing to your user, but while not making your application difficult to work with. You can use a sound file to notify a user of an event, or a video file demonstrating what the user must do next. I have wrapped most of the common MCI multimedia command in a class file. This will make it easier for you to use MCI in your applications.


Media Control Interface (MCI)

The Media Control Interface (MCI) provides standard commands for playing multimedia devices and recording multimedia resource files. These commands are a generic interface to nearly every kind of multimedia device. MCI provides applications with device-independent capabilities for controlling audio and visual peripherals. Your application can use MCI to control any supported multimedia device, including waveform-audio devices, MIDI sequencers, CD audio devices, and digital-video (video playback) devices.


mciSendString

The mciSendString function sends a command string to an MCI device. The device that the command is sent to is specified in the command string.


Enter the code

First we import the “winmm.dll” so that we can use the mciSendString function that we need.


DllImport("winmm.dll")

private static extern long mciSendString(string strCommand,

StringBuilder? strReturn, int iReturnLength, IntPtr? hwndCallback);


strCommand


Pointer to a null-terminated string that specifies an MCI command string.

For a list, see Multimedia Command Strings.


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_multimedia_command_strings.asp


strReturn


Pointer to a buffer that receives return information. If no return information is needed, this parameter can be null

.

iReturnLength


Size, in characters, of the return buffer specified by the strReturn parameter.


hwndCallback


Handle to a callback window if the "notify" flag was specified in the command string.


The open command


The open command initializes a device. All MCI devices recognize this command.

To send this command, call the mciSendString function with the strCommand parameter set as follows.



public void Open(string sFileName)
{

//mpegvideo is the device type that
//we are going to use
//the format of the song location
//must be with double quotes around it

sCommand = "open \"" + sFileName + "\" type

mpegvideo alias MediaFile";

mciSendString(sCommand, null, 0, IntPtr?.Zero);

}



We are using the mpegvideo device because we can play almost all of the newest media files with it, e.g. divx, xvid, mp3, avi, wav, mpeg, mpg and wmv.


The play command


The play command starts playing a device. CD audio, digital-video, MIDI sequencer, videodisc, VCR, and waveform-audio devices recognize this command. To send this command, call the mciSendString function with the strCommand parameter set as follows.



public void Play()
{
//tell the device to play

sCommand = "play MediaFile";

mciSendString(sCommand, null, 0, IntPtr?.Zero);

}


Conclusion:

I have only covered the basics in this tutorial; there are a lot more MCI function sitting in the wrapper that I wrote. Download the attached source code and demo application to get an idea of how to use the wrapper. You are all welcome to take the wrapper an improve/change it to suit your needs.


Happy coding !!!!


CLICKHERE TO DOWNLOAD SOURCE CODE

Notepad program written in C#(C Sharp).




Notepad program written in C#. Will show you how to use various dialogs in C#, how to copy&paste using clipboard and without clipboards, how to use windows registry for saving default setting of notepad, printing,and how to read and write a text file.


With this project you get idea about.

1. How to use various dialogs in C#.

-For opening and saving file
-For changing Forecolor and Backcolor
-For Print-Layout? and Printing

2. How to do copy/paste using clipboard and without clipboard.(Code commented for w/o clipboard)

3. How to use windows registry for saving default setting of notepad.

4. Reading and writing text file.


CLICKHERE TO DOWNLOAD SOURCE CODE

How to create a NotePad like editor in C#(CSharp)

Here is an example of how to create a NotePad? like editor in C#. This code involves the usage of ToolBar?, StatusBar?, Menu, File Manipulation and a lot of String Functions. For this project I tried to use as many basic aspects of C# functionality as possible.



CLICKHERE TO DOWNLOAD SOURCE CODE

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger