-
Code Error...
Code:
Imports System.IO
Public Class srec
Dim Encoder As WMEncoder
Dim quality = "Windows Media Video 8 for Local Area Network (384 Kbps)"
Dim savefold
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Please type a file name")
Else
Button1.Enabled = False
Button2.Enabled = True
MakeVideo()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button2.Enabled = False
Button1.Enabled = True
Encoder.Stop()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
AxWindowsMediaPlayer1.URL = "C:\SCVids\" + TextBox1.Text + ".avi"
Catch ex As Exception
End Try
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
quality = "Screen Video/Audio High (CBR)"
Else
quality = "Windows Media Video 8 for Local Area Network (384 Kbps)"
End If
End Sub
Private Sub MakeVideo()
Encoder = New WMEncoder
' Retrieve the source group collection and add a source group.
Dim SrcGrp As IWMEncSourceGroup2
Dim SrcGrpColl As IWMEncSourceGroupCollection
SrcGrpColl = Encoder.SourceGroupCollection
SrcGrp = SrcGrpColl.Add("SG_1")
' Add a video and audio source to the source group.
Dim SrcVid As IWMEncVideoSource2
Dim SrcAud As IWMEncAudioSource
SrcVid = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO)
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO)
' Identify the source files to encode.
SrcVid.SetInput("ScreenCap://ScreenCapture1")
SrcAud.SetInput("Device://Default_Audio_Device")
' Choose a profile from the collection.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim lLength As Long
ProColl = Encoder.ProfileCollection
lLength = ProColl.Count
For i = 0 To lLength - 1
Pro = ProColl.Item(i)
If Pro.Name = quality Then
SrcGrp.Profile = Pro
Exit For
End If
Next
' Specify a file object in which to save encoded content.
Dim File As IWMEncFile
File = Encoder.File
File.LocalFileName = "C:\SCVids\" + TextBox1.Text + ".avi"
' Crop 2 pixels from each edge of the video image.
SrcVid.CroppingBottomMargin = 2
SrcVid.CroppingTopMargin = 2
SrcVid.CroppingLeftMargin = 2
SrcVid.CroppingRightMargin = 2
' Start the encoding process.
Encoder.Start()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button2.Enabled = False
If Dir("C:\SCVids", vbDirectory) = "" Then MkDir("C:\SCVids")
End Sub
End Class
I want to create a screen recorder with this code but I receive these errors:
Code:
Warning 1 Type library importer encountered a property getter 'sessionPlaylistCount' on type 'WMPLib.IWMPNowPlayingHelperDispatch' without a valid return type. The importer will attempt to import this property as a method instead. Intelligent Robot OS
Warning 2 At least one of the arguments for 'IWMPGraphEventHandler.NotifyAcquireCredentials' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate. Intelligent Robot OS
Error 3 Type 'WMEncoder' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 5 20 Intelligent Robot OS
Error 4 'TextBox1' is not declared. It may be inaccessible due to its protection level. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 10 12 Intelligent Robot OS
Error 5 'TextBox1' is not declared. It may be inaccessible due to its protection level. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 28 56 Intelligent Robot OS
Error 6 Type 'WMEncoder' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 42 23 Intelligent Robot OS
Error 7 Type 'IWMEncSourceGroup2' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 44 23 Intelligent Robot OS
Error 8 Type 'IWMEncSourceGroupCollection' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 45 27 Intelligent Robot OS
Error 9 Type 'IWMEncVideoSource2' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 49 23 Intelligent Robot OS
Error 10 Type 'IWMEncAudioSource' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 50 23 Intelligent Robot OS
Error 11 'WMENC_SOURCE_TYPE' is not declared. It may be inaccessible due to its protection level. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 51 35 Intelligent Robot OS
Error 12 'WMENC_SOURCE_TYPE' is not declared. It may be inaccessible due to its protection level. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 52 35 Intelligent Robot OS
Error 13 Type 'IWMEncProfileCollection' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 57 24 Intelligent Robot OS
Error 14 Type 'IWMEncProfile' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 58 20 Intelligent Robot OS
Error 15 Type 'IWMEncFile' is not defined. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 71 21 Intelligent Robot OS
Error 16 'TextBox1' is not declared. It may be inaccessible due to its protection level. C:\Users\Catalin\documents\visual studio 2010\Projects\Intelligent Robot OS\Intelligent Robot OS\srec.vb 73 45 Intelligent Robot OS
-
Re: Code Error...
This is what happens when you copy and paste code from the net. The IDE is telling you exactly what you need to know. For example "'TextBox1' is not declared."
Do you have a textbox named textbox1 on your form? You will also need to reference the correct library's for WMEncoder.
You will also needed to add a reference to WMEncoder.dll and import Imports Interop.WMEncoder
Reference C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Interop.WMEncoder.dll