C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Play video files in .net


Posted Date: 07 Oct 2008      Total Responses: 2

Posted By: Yasotha       Member Level: Silver     Points: 1


hi

I would like to get the first frame of video file as an image. For that i am using ffmpeg. This code will first convert the uploading video file to flv format and create an image for first frame.

It is wokring well for some formats(like wmv)
But it's not convert some formats of video files(like avi) to flv...

is thr any other way to convert all types of video files to flv format?

Thanks in advance




Responses

Author: loki    07 Oct 2008Member Level: BronzeRating:     Points: -20
Hi,

Step 1: Create a new windows application. Open Visual Studio > File > New > Project > Windows Application > Rename it to ‘WindowsPlayAudio’.
Step 2: Drag and drop a label, 2 button controls and an OpenFileDialog component to the form. Rename them as follows :
Label1 – lblFile
Button1 – btnOpen
Button2 – btnPlay
TextBox – txtFileNm
OpenFileDialog – Set the Filter to ‘WAV Files|*.wav’
In the Form1.cs, add the following namespace
C#
using System.Media;
VB.NET
Imports System.Media
Step 3: On the ‘btnOpen’ click, display File Open dialog box and accept the selected .wav file in the txtFileNm textbox
C#
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txtFileNm.Text = openFileDialog1.FileName;
}
VB.NET
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
txtFileNm.Text = openFileDialog1.FileName
End If
Step 4: Code the btnPlay click event to play the selected file asynchronously
C#
private void btnPlay_Click(object sender, EventArgs e)
{
if (txtFileNm.Text != String.Empty)
{
SoundPlayer wavPlayer = new SoundPlayer();
wavPlayer.SoundLocation = txtFileNm.Text;
wavPlayer.LoadCompleted += new AsyncCompletedEventHandler(wavPlayer_LoadCompleted);
wavPlayer.LoadAsync();
}
}

private void wavPlayer_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
((System.Media.SoundPlayer)sender).Play();
}
VB.NET
Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As EventArgs)
If txtFileNm.Text <> String.Empty Then
Dim wavPlayer As SoundPlayer = New SoundPlayer()
wavPlayer.SoundLocation = txtFileNm.Text
AddHandler wavPlayer.LoadCompleted, AddressOf wavPlayer_LoadCompleted
wavPlayer.LoadAsync()
End If
End Sub

Private Sub wavPlayer_LoadCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
CType(sender, System.Media.SoundPlayer).Play()
End Sub

Step 5: That’s it. Run the application (F5). Click the Select File button and choose a .wav file. Click on the play button to play the file asynchronously.


loki.


Author: ashfaqq    07 Oct 2008Member Level: SilverRating:     Points: 1
play video in asp.net

visit :http://ramcrishna.blogspot.cm


Post Reply
You must Sign In to post a response.
Next : sending mail to (lot)mailId's asynchronously in c#
Previous : how to open a poppup window
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference call definitions

Contact Us    Privacy Policy    Terms Of Use