Jump to content

Botao Pause


TS91
 Share

Recommended Posts

Boas,

tenho estado a trabalhar num leitor de mp3 e video, mas deparei me com um erro, eu adiciono o filme ou musica, meto a tocar, o ficheiro corre mas se quiserer parar naquele monento  que estou a ver ou ouvir ele ao clicar no botao pause ele volta ao inicio do ficheiro, um erro que não da muito jeito quanto estou a ver um filme como calculam xD; eu tou a fazer o programa com 2 listbox uma escondida que é onde está os caminhos dos ficheiros e outra que mostar o nome do mesmo, eu queria saber com faço para meter o botao pause a funcionar.

Codigo utilizado para o botao

  MP_screen.Ctlcontrols.pause()

        play.Visible = True

        play.Enabled = True

Agradeço a todos os que ajudarem. 😄

Link to comment
Share on other sites

Public Class leitor
    'Varialvel que contrala o butao seguinte e anterior
    Dim music_ctrl As Integer
    Dim Ctrl_Pause As Integer
    Private Sub import_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles import.Click
        'Filtro do opendialog e comando para fazer aparecer o mesmo'
        importdiag.Filter = "Musica|*.mp3;*.wma;*.avi;*.mpg;*.sub;*.str"
        importdiag.ShowDialog()
    End Sub

    Private Sub importdiag_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles importdiag.FileOk
        'Adiciona cada musica ou filme do opendialog para a playlist e playlist2
        For Each track As String In importdiag.SafeFileNames '++++++Nome

            playlist.Items.Add(track)
            music_ctrl += 1
        Next
        For Each track As String In importdiag.FileNames '++++++Caminho

            playlist2.Items.Add(track)
        Next

        playlist.SelectedIndex = 0 '++++++ Mete o primeiro da lista Seleccionado
        playlist2.SelectedIndex = 0
    End Sub

    Private Sub play_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles play.Click
        
        If playlist.SelectedIndex = -1 Then
        Else
            MP_screen.URL = playlist2.SelectedItem
            play.Visible = False
            play.Enabled = False
            Timer1.Enabled = True


        End If
      


    End Sub

    Private Sub bt_stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_stop.Click
        'Faz que ao clicar no stop ele pare o que está a tocar e volte
        MP_screen.Ctlcontrols.stop()
        play.Visible = True
        play.Enabled = True
        Ctrl_Pause = True
    End Sub

    Private Sub bt_seguinte_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_seguinte.Click
        'Avança uma musica
        If playlist.SelectedIndex = -1 Then
            Exit Sub
        ElseIf playlist.SelectedIndex + 1 = music_ctrl Then
            playlist2.SelectedIndex = 0
            playlist.SelectedIndex = 0
            If play.Visible = False Then
                MP_screen.URL = playlist2.SelectedItem
                play.Visible = False
                play.Enabled = False
            Else
                play.Visible = True
                play.Enabled = True
            End If
        Else

            playlist2.SelectedIndex += 1
            playlist.SelectedIndex += 1
            If play.Visible = False Then
                MP_screen.URL = playlist2.SelectedItem
                play.Visible = False
                play.Enabled = False
            Else
                play.Visible = True
                play.Enabled = True
            End If
        End If


    End Sub

    Private Sub bt_anterior_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_anterior.Click
        'Retrodece uma musica
        If playlist.SelectedIndex = -1 Then
            Exit Sub
        ElseIf playlist.SelectedIndex = 0 Then
            playlist2.SelectedIndex = music_ctrl - 1
            playlist.SelectedIndex = music_ctrl - 1
            If play.Visible = False Then
                MP_screen.URL = playlist2.SelectedItem
                play.Visible = False
                play.Enabled = False
            Else
                play.Visible = True
                play.Enabled = True
            End If
        Else

            playlist2.SelectedIndex -= 1
            playlist.SelectedIndex -= 1
            If play.Visible = False Then
                MP_screen.URL = playlist2.SelectedItem
                play.Visible = False
                play.Enabled = False
            Else
                play.Visible = True
                play.Enabled = True
            End If
        End If

    End Sub

    Private Sub bt_pause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_pause.Click
        'Pausa a musica

        MP_screen.Ctlcontrols.pause()
        play.Visible = True
        play.Enabled = True
    End Sub

    Private Sub bt_vol_up_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_vol_up.Click
        'Aumenta o volume
        MP_screen.settings.volume += 10
    End Sub

    Private Sub bt_vol_down_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_vol_down.Click
        'Diminui o volume
        MP_screen.settings.volume -= 10
    End Sub

    Private Sub bt_som_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_som.Click
        'Tira o volume
        MP_screen.settings.mute = True
        bt_som.Visible = False
        bt_som.Enabled = False
    End Sub

    Private Sub bt_volume_off_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_volume_off.Click
        'Repoem o volume
        MP_screen.settings.mute = False
        bt_som.Visible = True
        bt_som.Enabled = True
    End Sub

    Private Sub playlist_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles playlist.SelectedIndexChanged
        playlist2.SelectedIndex = playlist.SelectedIndex '+++++ Iguala o index do um com o do 2

    End Sub

  
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        'Mostra o tempo a decorrer e o tempo total; controla a barra de tempo
        mp_progress.Maximum = MP_screen.currentMedia.duration
        mp_progress.Value = MP_screen.Ctlcontrols.currentPosition
        tempo_i.Text = MP_screen.Ctlcontrols.currentPositionString
        tempo_f.Text = MP_screen.currentMedia.durationString

        Ctrl_Pause = MP_screen.Ctlcontrols.currentPosition


    End Sub

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

        playlist.Items.Remove(playlist.SelectedItem)
        playlist2.Items.Remove(playlist2.SelectedItem)
    End Sub

    Private Sub MP_screen_DoubleClickEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_DoubleClickEvent) Handles MP_screen.DoubleClickEvent
        If MP_screen.fullScreen = False Then
            MP_screen.fullScreen = True
        Else
            MP_screen.fullScreen = False
        End If


    End Sub



    Private Sub bt_codecs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_codecs.Click
        System.Diagnostics.Process.Start((My.Computer.FileSystem.CurrentDirectory & "\TS91 Leitor\TS91 Leitor\bin\Debug\codecs.exe"))
    End Sub
End Class
Link to comment
Share on other sites

    Private Sub bt_codecs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_codecs.Click
        System.Diagnostics.Process.Start((My.Computer.FileSystem.CurrentDirectory & "\TS91 Leitor\TS91 Leitor\bin\Debug\codecs.exe"))
    End Sub
End Class

Isto só vai funcionar no teu computador 😄

Não usas o método play() em lado nenhum... só o método play() consegue retomar a reprodução.

Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.