制作播放列表问题(Windows Media Player) [英] Making Playlist problem (Windows Media Player)
问题描述
我在VB.net中使用Windows Media Player。
当我制作播放列表时,我收到了一个错误。
I am using Windows Media Player in VB.net.
When I make playlist, I got an error.
HRESULT异常:0x80040EA1
Exception from HRESULT: 0x80040EA1
Try
Dim p As WMPLib.IWMPPlaylist = Nothing
p = AxWindowsMediaPlayer1.playlistCollection.newPlaylist("test") <- ERROR
Catch ex As Exception
''
End Try
请h 我可以解决这个问题吗?
推荐答案
好吧我没有意识到如果发现错误你是怎么看错误的在Try / Catch中没有hing显示。
Well I don't realize how you see an error if the error is caught in a Try/Catch and there is nothing displayed.
但是如果添加了正确的引用,请尝试使用以下内容,因为我的代码可以使用,但我不需要在IWMPPlaylist之前提供WMPLIB,因为WMPLib在我的代码中被引用应用程序。也许通过将播放列表设置为Nothing最初导致问题为
我无法找到您的HRESULT的错误。
However if you have the correct reference added try the below as that works in my code although I don't have to provide WMPLIB before IWMPPlaylist since WMPLib is ref'd in my app. Perhaps by setting the playlist to Nothing originally causes the issue as I can't find what the error for your HRESULT is.
Imports WMPLibDim p As WMPLib.IWMPPlaylist = AxWindowsMediaPlayer1.playlistCollection.newPlaylist("test")
以下是旧程序的一些代码,但我不记得它是否有效。
Here's some further code from an old program but I can't remember if it worked or not.
Option Strict On
Imports WMPLib
Imports System.IO
Public Class Form1
WithEvents WMP1 As New WindowsMediaPlayer
Dim WMP1Burner As IWMPCdromBurn
Dim BurnerStatus As String = ""
Dim StartWMPBurn As Boolean = True
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
Label1.Text = "Waiting"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Create basic playlist
Dim playlst As IWMPPlaylist = WMP1.playlistCollection.newPlaylist("A Playlist by any other name")
playlst.setItemInfo("Genre", "Rock & roll")
playlst.setItemInfo("Year", "2010")
playlst.setItemInfo("Album Artist", "Some rock star")
playlst.setItemInfo("Album", "No Album just different Music")
'MessageBox.Show(playlst.getItemInfo("Album Artist").ToString)
'Exit Sub
Dim track() As String = Directory.GetFiles("C:\Users\John\Desktop\Test Music")
For i As Integer = 0 To track.Length - 1
playlst.appendItem(WMP1.newMedia(track(i)))
Next
WMP1.currentPlaylist = playlst
'WMP1.controls.stop()
WMP1.cdromCollection.getByDriveSpecifier("D")
Try
WMP1Burner = CType(WMP1.cdromCollection.Item(0), IWMPCdromBurn)
WMP1Burner.burnFormat = WMPBurnFormat.wmpbfAudioCD
WMP1Burner.burnPlaylist = WMP1.currentPlaylist
WMP1Burner.refreshStatus()
MessageBox.Show(WMP1.cdromCollection.count.ToString)
Catch ex As Exception
MessageBox.Show(ex.ToString & vbCrLf & ex.StackTrace.ToString)
End Try
'Validate Disk and Drive
If WMP1Burner.isAvailable("Burn") = False Then
MsgBox("The drive is NOT a CD Burner")
StartWMPBurn = False
End If
If WMP1Burner.isAvailable("Disc") = False Then
MsgBox("Drive is empty, please insert a blank CD-R.")
StartWMPBurn = False
End If
If WMP1Burner.isAvailable("Erase") = True Then
MsgBox("You are using a CD-RW isntead of a CD-R, do you want to continue?")
StartWMPBurn = False
End If
If WMP1Burner.isAvailable("Write") = False Then
MsgBox("Please insert a blank CD-R.")
StartWMPBurn = False
End If
If StartWMPBurn = False Then
'Exit Sub
End If
Try
MessageBox.Show(WMP1Burner.burnFormat.ToString)
WMP1Burner.startBurn()
Timer1.Start()
Catch ex As Exception
MessageBox.Show(ex.ToString & vbCrLf & ex.StackTrace.ToString)
End Try
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text = WMP1Burner.burnState.ToString
End Sub
End Class
这篇关于制作播放列表问题(Windows Media Player)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!