>

Rabu, 23 April 2014

Teknologi Multimedia



Pendahuluan
Membuat pemutar mp3, adalah suatu yang cukup penting didalam belajar pemograman multimedia. Untuk menci
ptakan suatu multimedia, unsur pemutar mp3 sangat dibutuhkan agar sebuah media dapat bersifat multimedia.
Tujuan
Mahasiswa dituntut agar bisa membuat sebuah aplikasi bersifat multimedia dengan menggunakan unsur pemutar mp3, sesuai dengan ketentuan yang telah ada.
Tools
Untuk praktikum ini saya menggunakan program Microsoft Visual Basic 6.0 sebagai creator utama program secara visual
Element-element yang dibutuhkan adalah
  • CommonDialog
  • Label
  • Frame
  • Line
  • Command
  • Windows Media Player
 Private Sub Command1_Click()
Dim spev As String
If last < 1 Then
Exit Sub
End If
    last = last - 1
    spev = List1.List(last)
    List1.ListIndex = List1.ListIndex - 1
    MediaPlayer1.FileName = spev
    MediaPlayer1.Play
    plays = ""
    Slider1.Max = MediaPleyer1.Duration
    Label1.Caption = List1.Text
End Sub


Private Sub Command10_Click()
If List1.ListIndex = -1 Then
Else
    List1.RemoveItem List1.ListIndex
    End If
End Sub
Private Sub Command11_Click()
List1.Clear
End Sub
Private Sub Command12_Click()
Dim sfile As String
With CommonDialog1
.CancelError = False
.Filter = "Mp3 Play list|*.mp1"
.ShowOpen
If .FileName = "" Then
Exit Sub
End If
sfile = CommonDialog1.FileName
CommonDialog1.FileName = ""
End With
List1.Clear
Dim a As String
Dim X As String
On Error GoTo error
Open sfile For Input As #1
Do Until EOF(1)
Input #1, a$
List1.AddItem a$
Loop
Close 1
Private Sub Command13_Click()
Dim i As Long
Dim sfile As String
With CommonDialog1
.CancelError = False
.Filter = "Mp3 Play list|*.mp1"
.ShowOpen
If .FileName = "" Then
Exit Sub
End If
sfile = CommonDialog1.FileName
CommonDialog1.FileName = ""
On Error GoTo error
Open sfile For Output As #1
For i = 0 To 100
    List1.ListIndex = i
    Write #1, List1.Text
Next i
error:
 Close #1
End Sub
Private Sub Command2_Click()
On Error Resume Next
MediaPlayer1.FileName = List1.Text
MediaPlayer1.Play
plays = ""
Slider1.Max = MediaPlayer1.Duration
Label1.Caption = List1.Text
End Sub
Private Sub Command3_Click()
On Error Resume Next
If MediaPlayer1.PlayState = 1 Then
    MediaPlayer1.Play
Else
    MediaPlayer1.Pause
End If
End Sub

Private Sub Command4_Click()
MediaPlayer1.Stop
End Sub
Private Sub Command5_Click()
On Error GoTo soo
Dim snext As String
last = last + 1
snext = List1.List(last)
List1.ListIndex = List1.ListIndex + 1
MediaPlayer1.FileName = snext
MediaPlayer1.Play
soo:
    last = List1.ListIndex
    plays = ""
    If List1.ListCount <> 0 Then
        Slider1.Max = MediaPlayer1.Duration
        Label1.Caption = List1.Text
    End If
End Sub
Private Sub Command6_Click()
Dim sfile As String
With CommonDialog1
.CancelError = False
.Filter = "MP3 Files|*.mp3"
.ShowOpen
End With
 If CommonDialog1.FileName = "" Then
 Exit Sub
 ElseIf Not Right$(CommonDialog1.FileName, 4) = ".mp3" Then
 Exit Sub
 End If
 sfile = CommonDialog1.FileName
 CommonDialog1.FileName = ""
 MediaPlayer1.FileName = sfile
 List1.Clear
 List1.AddItem sfile
 Slider1.Max = MediaPlayer1.Duration
 sfile = ""
 List1.ListIndex = 0
 Label1.Caption = List1.Text
End Sub
Private Sub Command7_Click()
If Command7.Caption = "Rep OFF" Then
Command7.Caption = "Rep ON"
sloop = "true"
ElseIf Command7.Caption = "Rep ON" Then
Command7.Caption = "Rep OFF"
sloop = "false"
End If
End Sub
Private Sub Command8_Click()
If Form1.Height = 7849 Then
    Form1.Height = 3720
ElseIf Form1.Height = 3720 Then
    Form1.Height = 7849
End If
End Sub
 End If
 End With
 sfile = CommonDialog1.FileName
 CommonDialog1.FileName = ""
 List1.AddItem sfile
 sfile = ""
 End Sub
Private Sub Form_Load()
plays = "stop"
sloop = "false"
Slider2.Value = 2500
Dim sfile, a As String
sfile = App.Path + "\" + "default.mp1"
On Error GoTo serr
Open sfile For Input As #1
Do Until EOF(1)
Input #1, a$
List1.AddItem a$
Loop
Close #1
serr:
Close #1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim sfile As String
Dim i As Long
sfile = App.Path + "\" + "default.mp1"
On Error GoTo error
Open sfile For Output As #1
For i = 0 To 100
List1.ListIndex = i
Write #1, List1.Text
Next i
error:
Close #1
End Sub

Private Sub List1_DblClick()
plays = "stop"
MediaPlayer1.FileName = List1.Text
MediaPlayer1.Play
Slider1.Max = MediaPlayer1.Duration
last = List1.ListIndex
Label1.Caption = List1.Text
End Sub
Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
If List1.ListIndex = -1 Then
Else
    List1.RemoveItem List1.ListIndex
End If
End If
End Sub
Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
    If Command7.Caption = "Rep Off" Then
    Exit Sub
    Else: MediaPlayer.Play
    End If
End Sub
Private Sub Slider1_Click()
MediaPlayer1.CurrentPosition = Slider1.Value
End Sub
Private Sub Slider1_Scroll()
MediaPlayer1.CurrentPosition = Slider1.Value
End Sub
Private Sub Slider2_Click()
MediaPlayer1.Volume = Slider2.Value - 2500
End Sub
Private Sub Slider2_Scroll()
MediaPlayer1.Volume = Slider2.Value - 2500
End Sub
Private Sub Timer1_Timer()
Slider1.Value = MediaPlayer1.CurrentPosition
End Sub
Private Sub Timer2_Timer()
Dim sekon As Long
Dim lengths, lengths1, min, sec As Long
lengths = MediaPlayer1.Duration
sekon = MediaPlayer1.CurrentPosition
lengths1 = lengths - sekon
min = lengths1 / 60
sec = lengths1 - min * 60

Label2.Caption = min & " : " & sec
End Sub
Open file










Tidak ada komentar:

Posting Komentar

Tulis Komentar Disini :