Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
  Friend WithEvents Button_PlayLive As System.Windows.Forms.Button
  Friend WithEvents AMC As AxAXISMEDIACONTROLLib.AxAxisMediaControl
  Friend WithEvents Button_Browse As System.Windows.Forms.Button
  Friend WithEvents Text_File As System.Windows.Forms.TextBox
  Friend WithEvents Button_Snapshot As System.Windows.Forms.Button
  Friend WithEvents SaveDlg As System.Windows.Forms.SaveFileDialog
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
    Me.Button_PlayLive = New System.Windows.Forms.Button()
    Me.AMC = New AxAXISMEDIACONTROLLib.AxAxisMediaControl()
    Me.Button_Browse = New System.Windows.Forms.Button()
    Me.Text_File = New System.Windows.Forms.TextBox()
    Me.Button_Snapshot = New System.Windows.Forms.Button()
    Me.SaveDlg = New System.Windows.Forms.SaveFileDialog()
    CType(Me.AMC, System.ComponentModel.ISupportInitialize).BeginInit()
    Me.SuspendLayout()
    '
    'Button_PlayLive
    '
    Me.Button_PlayLive.Location = New System.Drawing.Point(496, 8)
    Me.Button_PlayLive.Name = "Button_PlayLive"
    Me.Button_PlayLive.TabIndex = 2
    Me.Button_PlayLive.Text = "Play Live"
    '
    'AMC
    '
    Me.AMC.Enabled = True
    Me.AMC.Location = New System.Drawing.Point(8, 8)
    Me.AMC.Name = "AMC"
    Me.AMC.OcxState = CType(resources.GetObject("AMC.OcxState"), System.Windows.Forms.AxHost.State)
    Me.AMC.Size = New System.Drawing.Size(472, 352)
    Me.AMC.TabIndex = 3
    '
    'Button_Browse
    '
    Me.Button_Browse.Location = New System.Drawing.Point(400, 368)
    Me.Button_Browse.Name = "Button_Browse"
    Me.Button_Browse.TabIndex = 11
    Me.Button_Browse.Text = "Browse..."
    '
    'Text_File
    '
    Me.Text_File.Location = New System.Drawing.Point(240, 368)
    Me.Text_File.Name = "Text_File"
    Me.Text_File.ReadOnly = True
    Me.Text_File.Size = New System.Drawing.Size(160, 20)
    Me.Text_File.TabIndex = 10
    Me.Text_File.Text = "C:\AMC_Snapshot.jpg"
    '
    'Button_Snapshot
    '
    Me.Button_Snapshot.Location = New System.Drawing.Point(8, 368)
    Me.Button_Snapshot.Name = "Button_Snapshot"
    Me.Button_Snapshot.TabIndex = 9
    Me.Button_Snapshot.Text = "Snapshot"
    '
    'SaveDlg
    '
    Me.SaveDlg.FileName = "doc1"
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(584, 397)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button_Browse, Me.Text_File, Me.Button_Snapshot, Me.AMC, Me.Button_PlayLive})
    Me.Name = "Form1"
    Me.Text = "Form1"
    CType(Me.AMC, System.ComponentModel.ISupportInitialize).EndInit()
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub Button_PlayLive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_PlayLive.Click

    ' Set the media URL and the media type
    AMC.MediaURL = "axrtpu://10.13.24.77/mpeg4/media.amp"
    AMC.MediaType = "auto-sense"

    ' Start the download of the mpeg2 stream from the Axis camera/video server
    On Error GoTo ErrorHandler
    AMC.Play()
    Exit Sub

ErrorHandler:
    MsgBox("Error: " & Err.Description)

  End Sub

  Private Sub Button_Snapshot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Snapshot.Click

    On Error GoTo ErrorHandler
    AMC.SaveCurrentImage(0, Text_File.Text)
    Exit Sub

ErrorHandler:
    MsgBox("Error: " & Err.Description)

  End Sub

  Private Sub Button_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Browse.Click

    SaveDlg.Filter = "JPEG Image (*.jpg; *.jpeg) | *.jpg; *.jpeg ||"
    SaveDlg.FileName = Text_File.Text
    SaveDlg.ShowDialog()

    If SaveDlg.FileName <> "" Then

      Text_File.Text = SaveDlg.FileName

    End If

  End Sub

End Class
