Oppure

Loading
13/05/11 8:12
nightwolf
ho fatto come dici tu ma mi da sempre l'errore "Riferimento a un oggetto non impostato su un'istanza di oggetto", ho creato un form per fare una prova e tutto funziona, ma non riesco a capire dove posso modificare il mio progetto per far si che tutto funzioni.
aaa
13/05/11 12:56
walker93
Posta il codice con la posizione dell'errore
in questo momento più che dirti che c'è qualcosa che non va sulla dichiarazione di una variabile non posso fare...
aaa
18/05/11 11:27
nightwolf
eccomi ritornato scusate per l'attesa ecco il codice con l'errore prego di aiutarmi
aaa
18/05/11 12:31
walker93
Devo dire che è molto strano...
è POSSIBILE (non certo) che ci sia un problema in 3 punti
-O la label6 ha qualche problema, ma in questo caso ti avrebbe dato un errore differente
-O Durationstrig è vuoto, difficile che lo sia perche se non ci sono caricate canzoni dovrebbe mostrare 00:00
-O currentemedia è vuoto (direi la più probabile tra le 3) cioè non è stato dato nessun brano da riprodurre e di conseguenza è NULL

aaa
18/05/11 23:06
nightwolf
quindi credo che sia meglio mettere la label 6 in un altro timer e far si che si attivi quando clicco il pulsante play?
in questo modo currentmedia avrà qualcosa da riprodurre? tu che dici?
non ci sto capendo più niente, domani faccio le prove e faccio sapere qualcosa.
aaa
19/05/11 11:45
nightwolf
niente non funziona in nessun modo non so più cosa fare!!!
questo è l'intero cod. che uso.
aaa
19/05/11 11:47
nightwolf
aaa
19/05/11 11:47
nightwolf
eccolo
Imports WMPLib
Public Class media_player
Dim numero As Integer

Private Sub play()
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then
AxWindowsMediaPlayer1.Ctlcontrols.play()
Else
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem

End If
Button6.Text = "Pause"
End Sub
Private Sub Nexttrack()
Try
Dim s = ListBox1.SelectedIndex
Dim f = ListBox2.SelectedIndex
ListBox1.SelectedIndex = s + 1
ListBox2.SelectedIndex = f + 1
play()
Catch ex As Exception
AxWindowsMediaPlayer1.URL = ""
Button1.Text = "Play"
End Try
End Sub

Private Sub Previoustrack()
Try
Dim s = ListBox1.SelectedIndex
Dim f = ListBox2.SelectedIndex
ListBox1.SelectedIndex = s - 1
ListBox2.SelectedIndex = f - 1
play()
Catch ex As Exception
AxWindowsMediaPlayer1.URL = ""
Button1.Text = "Play"
End Try
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
PictureBox1.Visible = False
AxWindowsMediaPlayer1.Visible = True
ListBox2.Visible = True
Dim open As New OpenFileDialog
Try
open.Title = "open Music"
open.FileName = ""
open.Multiselect = True
open.Filter = "MP3 file(*.MP3)|*.MP3|All files (*.*)|*.*"
If open.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each Track As String In open.FileNames
ListBox1.Items.Add(Track)
Next
For Each trackname As String In open.SafeFileNames
ListBox2.Items.Add(trackname)
Next
End If
Catch ex As Exception

End Try
numero = ListBox2.Items.Count
Label4.Text = numero
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ListBox1.SelectedIndex = ListBox2.SelectedIndex
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
Try
Nexttrack()
Catch ex As Exception
AxWindowsMediaPlayer1.URL = ""
End Try
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer2.Enabled = True
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Label5.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
AxWindowsMediaPlayer1.Ctlcontrols.pause()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PictureBox1.Visible = True
AxWindowsMediaPlayer1.Visible = False
ListBox2.Visible = False
AxWindowsMediaPlayer1.URL = ""
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Nexttrack()
Label5.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Previoustrack()
Label5.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.name
End Sub

Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
AxWindowsMediaPlayer1.settings.volume = TrackBar1.Value
End Sub

Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
AxWindowsMediaPlayer1.settings.balance = TrackBar2.Value
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxWindowsMediaPlayer1.Visible = False
ListBox2.Visible = False
TrackBar1.Value = AxWindowsMediaPlayer1.settings.volume
TrackBar2.Value = AxWindowsMediaPlayer1.settings.balance
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TrackBar2.Value = 0
AxWindowsMediaPlayer1.settings.balance = 0
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
AxWindowsMediaPlayer1.fullScreen = True

End Sub

Private Sub AxWindowsMediaPlayer1_ClickEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_ClickEvent) Handles AxWindowsMediaPlayer1.ClickEvent
AxWindowsMediaPlayer1.fullScreen = False
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer2.Interval = 60
Label3.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString
TrackBar3.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Label6.Text = AxWindowsMediaPlayer1.currentMedia.durationString
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Me.Close()
End Sub

Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = TrackBar3.Value
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
controlli.Show()
End Sub

Private Sub TrackBar1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.VisibleChanged
TrackBar1.Value = controlli.TrackBar1.Value
End Sub

Private Sub Rechts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
AxWindowsMediaPlayer1.stretchToFit = True
If CheckBox1.Checked = True Then
If AxWindowsMediaPlayer1.playState = WMPPlayState.wmppsPlaying Then
'nothing
ElseIf AxWindowsMediaPlayer1.playState = WMPPlayState.wmppsStopped = True Then
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
ListBox2.SelectedIndex = ListBox2.SelectedIndex + 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem

End If

End If
End Sub

End Class
Ultima modifica effettuata da nightwolf 19/05/11 11:55
aaa