Imports WMPLib
Imports System.IO
Public Class Form1
Dim playlist As IWMPPlaylist = Nothing
Dim unsaved As String = My.Computer.FileSystem.SpecialDirectories.Temp & "\" & "Unsaved.m3u"
Private Sub OpenFilesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFilesToolStripMenuItem.Click
Dim ofd As New OpenFileDialog
ofd.RestoreDirectory = True
ofd.Filter = ""
If ofd.FilterIndex = 2 Then
ofd.Multiselect = False
Else
ofd.Multiselect = True
End If
ofd.Title = "เปิดไฟล์"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Clear()
Using sw As New StreamWriter(unsaved, False)
For Each song As String In ofd.FileNames
sw.WriteLine(song)
Next
End Using
ListBox1.Items.Clear()
playlist = player.newPlaylist("Unsaved Playlist", unsaved)
player.currentPlaylist = playlist
For i = 0 To player.currentPlaylist.count - 1
ListBox1.Items.Add(player.currentPlaylist.Item(i).name)
Next
ListBox1.SelectedItem = player.Ctlcontrols.currentItem.name
Play1.Image = My.Resources.pause1
My.Settings.LastPlaylist = unsaved
End If
End Sub
Public Shared Function encode(ByVal str As String) As String
Dim utf8Encoding As New System.Text.UTF8Encoding(True)
Dim encodedString() As Byte
encodedString = utf8Encoding.GetBytes(str)
Return utf8Encoding.GetString(encodedString)
End Function
ลองใช้การ Encode ให้เป็นแบบ UTF-8 ดูก่อนครับ ถ้าไม่ได้ แสดงว่าไม่ Support ภาษาไทยครับ