Start Audio file With Specific Position

No.of Views857
Bookmarked0 times
Downloads 
Votes0
By  kirtan007   On  16 Feb 2010 00:02:48
Tag : CSharp , Windows Forms
Start Audio file With Specific Position
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

Many time We Want to Start Some Audio File Not from Starting but Want to Start playing from Specific TimeSpan

Here i gona show you how to do that thing easily

Technologies:

.net 2.0/3.5

Language:


C#

Prerequisite

1. .NET Framework 3.5/2.0

2. Visual Studio 2008/2005


Implementation

assumes that you have all prerequestites .

Just Take a Label to Show Current Position of Media on Form and Dragdrop One timer Say "timer1"

Follow the Steps




Step 2




Step 3


using System.Windows.Media;

namespace WindowsFormsApplication32

{

public partial class Form1 : Form

{

MediaPlayer m;

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

// Create Instance

m = new MediaPlayer();

m.Open(new Uri(@"D:\Songs\Angel.mp3"));

m.Play();

//Set Position Where you want to Start Here we starting from 0:1:50

m.Position = new TimeSpan(0, 1, 50);

timer1.Enabled = true;

}

private void timer1_Tick(object sender, EventArgs e)

{

// Current Position of MediaFile

label1.Text = m.Position.ToString();

}

}

You are done How Simple it was !!

Conclusion

Article Explaines how to play audio files from specific time span

Thanks .

 
Sign Up to vote for this article
 
About Author
 
kirtan007
Occupation-
Company-
Member Type-Senior
Location-Not Provided
Joined date-02 Jul 2009
Home Page-http://kirtan.uni.cc
Blog Page-
He completed his Bachelor of Computer Application from Gujarat University 2009 .He is doing Master of Computer Application from Gujarat Technological University right now .. His area of Interests are Web Hacking , C# .net Windows form ,asp.net , WPF ,Silverlight ,SQL Server and Some PHP.
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top