Attribute VB_Name = "modSubroutines" Option Explicit Public strFileName As String Public strFileType As String ' This integer is used to trim off ' the filename's path and store just ' the name into a new variable (strName) ' so that the filename can be displayed ' on the form. See this in the For...Next ' loop in the cmdOpenFile subroutine. Public i As Integer Public strName As String ' While the media plays, the filename ' wraps around the screen. This integer ' holds the initial position of the text, ' so that if the file is stopped, the ' filename's text returns to its normal ' position. Public intLabelPosition As Integer ' Issuing the "Close" command to the MMcontrol ' stops the file from playing. It also drops the ' drivers. The StopValue tells the Play button ' whether the file has been paused or stopped, ' because the StopValue is set to 1 when the ' Stop button is pressed. This number is set to ' 0 when the Play button is pressed ' to reset this. Public StopValue As Integer Public Sub SelectDrivers() frm1337MP.MMControl1.Command = "Close" ' This subroutine selects specific drivers for the ' filetype based on its extension. The extension ' is stripped off of the filename and stored in ' strFileType. strFileType = Right(strFileName, 3) ' This is a Select Case statement that sorts ' through all of the different possibilities for ' strFileType and chooses the proper driver ' based upon the result With frm1337MP.MMControl1 Select Case strFileType Case "wav" .DeviceType = "WaveAudio" Case "mp3", "mpg", "mpeg" .DeviceType = "MpegVideo" Case "mid", "midi" .DeviceType = "Sequencer" Case "avi" .DeviceType = "AviVideo" Case "cda" .DeviceType = "CDAudio" Case Else .DeviceType = "Other" End Select .Command = "Open" End With End Sub Public Sub EnablePlayBack() ' If the filetype is not supported, display ' this message. Otherwise, enable playback. If frm1337MP.MMControl1.Length = 0 Then MsgBox "This filetype is not supported by" & _ "1337MP, or it is not a valid media file.", , "Error" Else frm1337MP.cmdPlay.Enabled = True frm1337MP.cmdPause.Enabled = False frm1337MP.cmdStop.Enabled = False Call TrimName Call SetLabelPos End If End Sub Public Sub TrimName() ' See note for i (top of code) For i = 1 To Len(strFileName) strName = Mid$(strFileName, Len(strFileName) - i, 1) If strName = "\" Then strName = Right$(strFileName, i) Exit For End If Next i frm1337MP.lblFileName = strName End Sub Public Sub SetLabelPos() ' This sets the position of the filename ' to be exactly half way across the form. If intLabelPosition <> 0 Then frm1337MP.lblFileName.Left = (frm1337MP.Width - frm1337MP.lblFileName.Width) / 2 intLabelPosition = frm1337MP.lblFileName.Left Else intLabelPosition = frm1337MP.lblFileName.Left End If End Sub