Create Microsoft Media file type *.ASX using VB.net

'Create Microsoft Media file type *.ASX using VB.net

'By wgscd

'http://blog.csdn.net/wgsnet

'2008/11/3

 

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    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

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
    Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
    Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox
    Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
    Friend WithEvents CheckBox4 As System.Windows.Forms.CheckBox
    Friend WithEvents TextBox8 As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents TextBox9 As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.ProgressBar1 = New System.Windows.Forms.ProgressBar
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.TextBox4 = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.TextBox5 = New System.Windows.Forms.TextBox
        Me.CheckBox1 = New System.Windows.Forms.CheckBox
        Me.CheckBox3 = New System.Windows.Forms.CheckBox
        Me.TextBox6 = New System.Windows.Forms.TextBox
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.TextBox9 = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.TextBox8 = New System.Windows.Forms.TextBox
        Me.CheckBox4 = New System.Windows.Forms.CheckBox
        Me.TextBox7 = New System.Windows.Forms.TextBox
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'RichTextBox1
        '
        Me.RichTextBox1.Location = New System.Drawing.Point(16, 32)
        Me.RichTextBox1.Name = "RichTextBox1"
        Me.RichTextBox1.Size = New System.Drawing.Size(544, 168)
        Me.RichTextBox1.TabIndex = 0
        Me.RichTextBox1.Text = ""
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(80, 24)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(224, 21)
        Me.TextBox1.TabIndex = 1
        Me.TextBox1.Text = "TextBox1"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(504, 216)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(80, 32)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "工作"
        '
        'ProgressBar1
        '
        Me.ProgressBar1.Location = New System.Drawing.Point(40, 224)
        Me.ProgressBar1.Name = "ProgressBar1"
        Me.ProgressBar1.Size = New System.Drawing.Size(432, 16)
        Me.ProgressBar1.TabIndex = 3
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(536, 24)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(56, 21)
        Me.TextBox2.TabIndex = 4
        Me.TextBox2.Text = "100"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(464, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(64, 23)
        Me.Label1.TabIndex = 5
        Me.Label1.Text = "最大值"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(320, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(64, 23)
        Me.Label2.TabIndex = 6
        Me.Label2.Text = "初始数"
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(392, 24)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(56, 21)
        Me.TextBox3.TabIndex = 7
        Me.TextBox3.Text = "0"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(8, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(64, 23)
        Me.Label3.TabIndex = 8
        Me.Label3.Text = "基础地址"
        '
        'TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(120, 32)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(192, 21)
        Me.TextBox4.TabIndex = 9
        Me.TextBox4.Text = "wgscd(自由奔腾) @ 2005"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(24, 32)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(80, 23)
        Me.Label4.TabIndex = 10
        Me.Label4.Text = "Copyright"
        '
        'TextBox5
        '
        Me.TextBox5.Location = New System.Drawing.Point(456, 32)
        Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(40, 21)
        Me.TextBox5.TabIndex = 11
        Me.TextBox5.Text = "00:04"
        '
        'CheckBox1
        '
        Me.CheckBox1.Location = New System.Drawing.Point(360, 32)
        Me.CheckBox1.Name = "CheckBox1"
        Me.CheckBox1.Size = New System.Drawing.Size(88, 24)
        Me.CheckBox1.TabIndex = 12
        Me.CheckBox1.Text = "跳转时间"
        '
        'CheckBox3
        '
        Me.CheckBox3.Location = New System.Drawing.Point(360, 64)
        Me.CheckBox3.Name = "CheckBox3"
        Me.CheckBox3.Size = New System.Drawing.Size(112, 24)
        Me.CheckBox3.TabIndex = 15
        Me.CheckBox3.Text = "演唱(作者)"
        '
        'TextBox6
        '
        Me.TextBox6.Location = New System.Drawing.Point(456, 64)
        Me.TextBox6.Name = "TextBox6"
        Me.TextBox6.Size = New System.Drawing.Size(104, 21)
        Me.TextBox6.TabIndex = 16
        Me.TextBox6.Text = "wgscd"
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.RichTextBox1)
        Me.GroupBox1.Location = New System.Drawing.Point(16, 248)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(576, 216)
        Me.GroupBox1.TabIndex = 17
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "文件内容"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.TextBox6)
        Me.GroupBox2.Controls.Add(Me.Label6)
        Me.GroupBox2.Controls.Add(Me.TextBox9)
        Me.GroupBox2.Controls.Add(Me.Label5)
        Me.GroupBox2.Controls.Add(Me.TextBox8)
        Me.GroupBox2.Controls.Add(Me.CheckBox4)
        Me.GroupBox2.Controls.Add(Me.TextBox7)
        Me.GroupBox2.Controls.Add(Me.CheckBox3)
        Me.GroupBox2.Controls.Add(Me.TextBox4)
        Me.GroupBox2.Controls.Add(Me.TextBox5)
        Me.GroupBox2.Controls.Add(Me.Label4)
        Me.GroupBox2.Controls.Add(Me.CheckBox1)
        Me.GroupBox2.Location = New System.Drawing.Point(16, 56)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(576, 152)
        Me.GroupBox2.TabIndex = 18
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "GroupBox2"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(24, 72)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(64, 23)
        Me.Label6.TabIndex = 22
        Me.Label6.Text = "列表名"
        '
        'TextBox9
        '
        Me.TextBox9.Location = New System.Drawing.Point(376, 104)
        Me.TextBox9.Name = "TextBox9"
        Me.TextBox9.Size = New System.Drawing.Size(184, 21)
        Me.TextBox9.TabIndex = 21
        Me.TextBox9.Text = "TextBox9"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(320, 104)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(48, 23)
        Me.Label5.TabIndex = 20
        Me.Label5.Text = "连接"
        '
        'TextBox8
        '
        Me.TextBox8.Location = New System.Drawing.Point(120, 104)
        Me.TextBox8.Name = "TextBox8"
        Me.TextBox8.Size = New System.Drawing.Size(192, 21)
        Me.TextBox8.TabIndex = 19
        Me.TextBox8.Text = "TextBox8"
        '
        'CheckBox4
        '
        Me.CheckBox4.Location = New System.Drawing.Point(16, 104)
        Me.CheckBox4.Name = "CheckBox4"
        Me.CheckBox4.Size = New System.Drawing.Size(112, 24)
        Me.CheckBox4.TabIndex = 18
        Me.CheckBox4.Text = "广告图片URL"
        '
        'TextBox7
        '
        Me.TextBox7.Location = New System.Drawing.Point(120, 72)
        Me.TextBox7.Name = "TextBox7"
        Me.TextBox7.Size = New System.Drawing.Size(192, 21)
        Me.TextBox7.TabIndex = 17
        Me.TextBox7.Text = "我的歌曲列表"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(606, 468)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.ProgressBar1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.MaximizeBox = False
        Me.Name = "Form1"
        Me.Text = "ASX"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        If TextBox1.Text = "" Then

            MsgBox("BaseURL不能为空")

            Exit Sub

        ElseIf TextBox3.Text = "" Then


            MsgBox("Base Number不能为空")

            Exit Sub


        ElseIf TextBox2.Text = "" Then

 

            MsgBox("Max不能为空")

            Exit Sub

 

        End If

 

 

        Dim Max As Integer = CInt(TextBox2.Text) - CInt(TextBox3.Text)

        ProgressBar1.Maximum = Max

        Dim sb As New System.Text.StringBuilder

        sb.Append("<asx version=""3.0"">" & vbCrLf & "<Title>" & TextBox7.Text & "</Title>" & vbCrLf & "<copyright>" & TextBox4.Text & "</copyright>" & vbCrLf) '公共部分

 


        If Me.CheckBox4.Checked = True Then

            If CheckBox1.Checked = True Then '在广告图片URL没设置开启的的前提下如果跳转时间设置“开启“


                sb.Append("<BANNER HREF=""" & TextBox8.Text & """><moreinfo href=""" & TextBox9.Text & """/></BANNER>" & vbCrLf)
                Dim j As Integer = 0
                For i As Integer = CInt(Me.TextBox3.Text) To CInt(Me.TextBox2.Text)
                    sb.Append("<entry><ref href=""")

                    sb.Append(TextBox1.Text & i & ".jpg"" />" & vbCrLf)

                    sb.Append("<duration value=""" & TextBox5.Text & """/></entry>" & vbCrLf)

                    Me.ProgressBar1.Value = j
                    j += 1
                Next


                sb.Append("</asx>")


            Else '在广告图片URL没设置开启的的前提下如果跳转时间设置“不开启“

 

                sb.Append("<BANNER HREF=""" & TextBox8.Text & """><moreinfo href=""" & TextBox9.Text & """/></BANNER>" & vbCrLf)
                Dim j As Integer = 0
                For i As Integer = CInt(Me.TextBox3.Text) To CInt(Me.TextBox2.Text)
                    sb.Append("<entry><ref href=""")

                    sb.Append(TextBox1.Text & i & ".jpg"" />" & vbCrLf & "</entry>" & vbCrLf)

                    Me.ProgressBar1.Value = j
                    j += 1
                Next

                sb.Append("</asx>")


            End If

        Else


            If CheckBox1.Checked = True Then '在广告图片URL没设置开启的的前提下如果跳转时间设置“开启”
                Dim j As Integer = 0
                For i As Integer = CInt(Me.TextBox3.Text) To CInt(Me.TextBox2.Text)

                    sb.Append("<entry><ref href=""")

                    sb.Append(TextBox1.Text & i & ".jpg"" />" & vbCrLf)

                    sb.Append("<duration value=""" & TextBox5.Text & """/></entry>" & vbCrLf)

                    Me.ProgressBar1.Value = j
                    j += 1
                Next


                sb.Append("</asx>")

            Else '在广告图片URL没设置开启的的前提下如果跳转时间设置“不开启”

                Dim j As Integer = 0
                For i As Integer = CInt(Me.TextBox3.Text) To CInt(Me.TextBox2.Text)

                    sb.Append("<entry><ref href=""")

                    sb.Append(TextBox1.Text & i & ".jpg"" />" & vbCrLf & "</entry>" & vbCrLf)

                    Me.ProgressBar1.Value = j
                    j += 1
                Next


                sb.Append("</asx>")


        End If


        End If

        Me.RichTextBox1.Text = sb.ToString

        '写入文件
        Dim SavePath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) & "/ASX播放列表.asx"

        Dim sW As New IO.StreamWriter(IO.File.Create(SavePath), System.Text.Encoding.GetEncoding("gb2312"))

        sW.Write(sb)

        sW.Close()

        '播放列表文件

        Dim p As New Process
        p.Start(System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) & "/ASX播放列表.asx")

 


    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CheckBox1.Checked = False
        Me.TextBox5.Enabled = False

 

        CheckBox3.Checked = False
        Me.TextBox6.Enabled = False

        Me.TextBox1.Text = ""

        Me.RichTextBox1.Text = ""


        CheckBox4.Checked = False

        TextBox8.Enabled = False
        TextBox9.Enabled = False

        TextBox8.Text = "http://blog.csdn.net/images/blog_csdn_net/wgsnet/97899/o_MySongLog.gif"
        TextBox9.Text = "http://blog.csdn.net/wgsnet"


    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then

            Me.TextBox5.Enabled = True
        Else

            Me.TextBox5.Enabled = False

        End If
    End Sub

   

    Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

    End Sub

    Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged

        If CheckBox4.Checked = True Then

            TextBox8.Enabled = True
            TextBox9.Enabled = True
        Else

            TextBox8.Enabled = False

            TextBox9.Enabled = False

        End If


    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged

 

        If CheckBox3.Checked = True Then

            TextBox6.Enabled = True

        Else

            TextBox6.Enabled = False


        End If

 

    End Sub
   
End Class

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值