C# Developer Getting Started
|
c# Developer Getting Started |
Assuming that you have already run the Movie Maker Timeline Control Control installation program and started visual studio 2010, the next step is create New Project, select Windows Form Application.
In Toolbox, Right Click mouse and Select Choose Items... , Select Movie Maker Timeline Control in COM Components Tab.
Now you will see the Movie Maker Timeline Control on Toolbox, Drag the Movie Maker Timeline Control from Toolbox to form. add button and picturebox on form.
Add following code in Button click event. It will setup the preview window on picturebox.
private void button1_Click(object sender, EventArgs e) axTimelineControl1.SetPreviewWnd((int)pictureBox1.Handle); } |
Add following code in Button click event. It will add video clip and audio clip on timeline control.
private void button1_Click(object sender, EventArgs e) axTimelineControl1.SetPreviewWnd((int)pictureBox1.Handle); string strVideo1="c:\\yourfolder\\yourfile.mpg"; float iVideo1Duration= axTimelineControl1.GetMediaDuration(strVideo1); axTimelineControl1.AddVideoClip(axTimelineControl1.GetVideo1TrackIndex(), strVideo1, 0, iVideo1Duration, 0); axTimelineControl1.AddAudioClip(axTimelineControl1.GetAudio1TrackIndex(), strVideo1, 0, iVideo1Duration, 0, 1); axTimelineControl1.Play(); } |
Now you can run the sample and click the button to play the timeline.
Finally add another button on form , change the button 1's caption to Play, change button 2's caption to Save.
Add following code in Save Button click event. It will save to MP4 video.
private void button2_Click(object sender, EventArgs e) axTimelineControl1.OutputType = 2; axTimelineControl1.MP4AspectRatio = 0; axTimelineControl1.MP4AudioBitrate = 96000; axTimelineControl1.MP4AudioChannels = 2; axTimelineControl1.MP4AudioSampleRate =44100; axTimelineControl1.MP4Framerate = 25; axTimelineControl1.MP4H264Preset = 0; axTimelineControl1.MP4Height = 480; axTimelineControl1.MP4Width = 720; axTimelineControl1.MP4VideoBitrate = 5000000; axTimelineControl1.Save("c:\\yourfolder\\yourfile.mp4"); } |
When conversion completed, it will fired OnConvertCompleted event, Add following code in in OnConvertCompleted.
private void axTimelineControl1_OnConvertCompleted(object sender, EventArgs e) MessageBox.Show("Save Completed"); } |
Now run the project, click Play button, then click Save button, you will see the video added to timeline, preview the video and converting the video in same time.