ByteScout SWF To Video SDK – VB.NET – SWF to WMV with live preview

  • Home
  • /
  • Articles
  • /
  • ByteScout SWF To Video SDK – VB.NET – SWF to WMV with live preview

ByteScout SWF To Video SDK – VB.NET – SWF to WMV with live preview

Form1.vb

Imports System.Drawing
Imports System.Windows.Forms
Imports BytescoutSWFToVideo

Public Partial Class Form1
	Inherits Form
	Private m_g As Graphics
	Private m_hdc As IntPtr
	Private swf As New SWFToVideoClass()

	Public Sub New()
		InitializeComponent()
	End Sub

    Private Sub buttonConvert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonConvert.Click
        If Not swf.IsRunning Then
            swf.SWFConversionMode = SWFConversionModeType.SWFWithLiveData
            swf.ConversionTimeOut = 15000

            swf.InputSWFFileName = "test.swf"
            swf.OutputVideoFileName = "test.wmv"
            swf.OutputWidth = 640
            swf.OutputHeight = 480

            swf.SetPreviewContext(m_hdc.ToInt32(), 0, 0, pictureBox1.Width, pictureBox1.Height, 30)
            swf.Run()
        End If
    End Sub

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Shown
        m_g = pictureBox1.CreateGraphics()
        m_hdc = m_g.GetHdc()
    End Sub

    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs) Handles MyBase.FormClosed
        m_g.ReleaseHdc(m_hdc)
        m_g.Dispose()

	' release resources
	System.Runtime.InteropServices.Marshal.ReleaseComObject(swf)
	swf = Nothing

    End Sub
End Class

Program.vb

' x64 IMPORTANT NOTE: set CPU to x86 to build in x86 mode. WHY? Because flash is not supported on x64 platform currently at all
Imports System.Collections.Generic
Imports System.Windows.Forms

NotInheritable Class Program
	Private Sub New()
	End Sub
	''' <summary>
	''' The main entry point for the application.
	''' </summary>
	<STAThread> _
	Friend Shared Sub Main()
		Application.EnableVisualStyles()
		Application.SetCompatibleTextRenderingDefault(False)
		Application.Run(New Form1())
	End Sub
End Class


  Click here to get your Free Trial version of the SDK

prev
next