VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "cMusic" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Objeto responsável por armazenar dados de música ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Nome da classe Private Const ST_MY_NAME As String = "cMusic" ' Faixa Private st_Title As String ' Artista Private st_Artist As String ' Álbum Private st_Album As String ' Duração da faixa Private ln_Duration As Long ' Endereço do arquivo Private st_FileAddress As String ' Tamanho do arquivo Private ln_FileSize As Long ' ID da música (internamente) Private ln_ID As Long ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades da faixa ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get Title() As String ' Retorna Title = st_Title End Property Public Property Let Title(stInput As String) ' Seta st_Title = stInput End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades do artista ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get Artist() As String ' Retorna Artist = st_Artist End Property Public Property Let Artist(stInput As String) ' Seta st_Artist = stInput End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades do álbum ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get Album() As String ' Retorna Album = st_Album End Property Public Property Let Album(stInput As String) ' Seta st_Album = stInput End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades da duração (em segundos) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get Duration() As Long ' Retorna Duration = ln_Duration / 1000 End Property Public Property Let Duration(lnInput As Long) On Error GoTo ErrTreat: ' Seta ln_Duration = lnInput * 1000 Exit Property ErrTreat: ' Invalida duração ln_Duration = LN_INVALID_VALUE End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades da duração (em milisegundos) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get MiliDuration() As Long ' Retorna MiliDuration = ln_Duration End Property Public Property Let MiliDuration(lnInput As Long) ' Seta ln_Duration = lnInput End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades do endereço do arquivo ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get FileAddress() As String ' Retorna FileAddress = st_FileAddress End Property Public Property Let FileAddress(stInput As String) ' Se for diferente do atual If (stInput <> st_FileAddress) Then ' Seta st_FileAddress = stInput ' Atualida ID updateID End If ' Atualiza tamanho do arquivo updateFileSize End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades do tamanho do arquivo ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get FileSize() As Long ' Retorna FileSize = ln_FileSize End Property Public Property Let FileSize(lnInput As Long) ' Seta ln_FileSize = lnInput End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades da ID da música ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get ID() As Long ' Retorna ID = ln_ID End Property Public Property Let ID(lnInput As Long) ' Seta ln_ID = lnInput End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Se a música é válida ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get IsValid() As Boolean ' Se campo Artista E campo Título forem válidos IsValid = IsValidArtist And IsValidTitle End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Se artista é válido ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get IsValidArtist() As Boolean ' Se campo Artista E campo Título forem válidos IsValidArtist = (st_Artist <> ST_INVALID_VALUE) End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Se título é válido ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get IsValidTitle() As Boolean ' Se campo Artista E campo Título forem válidos IsValidTitle = (st_Title <> ST_INVALID_VALUE) End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Gera uma nova ID ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub updateID() Dim itI As Integer On Error Resume Next ' Inicia valor ln_ID = LN_INVALID_VALUE ' Varre o endereço do arquivo For itI = Len(st_FileAddress) To 1 Step -1 ' Adiciona char ln_ID = ln_ID + (Asc(Mid(st_FileAddress, itI, 1)) * itI) Next itI End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Armazena o tamanho do arquivo ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub updateFileSize() On Error GoTo ErrTreat: ' Recupera o tamanho do arquivo ln_FileSize = FileLen(st_FileAddress) Exit Sub ErrTreat: ' Seta tamanho como sendo o tamanho do caminho do arquivo ln_FileSize = Len(st_FileAddress) End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Reseta os dados ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub Reset() ' Reseta valores Title = ST_INVALID_VALUE Artist = ST_INVALID_VALUE Album = ST_INVALID_VALUE Duration = LN_INVALID_VALUE ln_ID = LN_INVALID_VALUE End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades para obtenção do info geral da música ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get Info() As String ' Retorna Info = wstringTOwchar(Artist) + ST_SEP + _ wstringTOwchar(Album) + ST_SEP + _ wstringTOwchar(Title) + ST_SEP + _ CStr(Duration) End Property Public Property Get InfoW() As String ' Retorna InfoW = Artist + ST_EXTRA_SEP + _ Album + ST_EXTRA_SEP + _ Title + ST_EXTRA_SEP + _ CStr(Duration) End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades para obtenção da IDTAG da música ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get IDTag() As String Dim stAux As String On Error Resume Next ' Inicia retorno stAux = ST_INVALID_VALUE ' Se há álbum If (st_Album <> ST_INVALID_VALUE) Then ' Concatena album stAux = stAux + "[al:" + st_Album + "]" + ST_LINESEP End If ' Se há artista If (st_Artist <> ST_INVALID_VALUE) Then ' Concatena artista stAux = stAux + "[ar:" + st_Artist + "]" + ST_LINESEP End If ' Se há título If (st_Title <> ST_INVALID_VALUE) Then ' Concatena título stAux = stAux + "[ti:" + st_Title + "]" + ST_LINESEP End If ' Concatena nome do programa stAux = stAux + "[re:" + ST_LYRIK_NAME + "]" + ST_LINESEP ' Concatena versão do programa stAux = stAux + "[ve:" + ST_LYRIK_VERSION + "]" + ST_LINESEP ' Retorna IDTag = stAux End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Propriedades para obtenção do título (Artista - Faixa) da música ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get MusicTitle() As String ' Se há artista válido If IsValidArtist Then ' Se há título válido If IsValidTitle Then ' Incrementa com título da faixa MusicTitle = Artist + ST_EXTRA_SEP + Title Else ' Retorna apenas artista MusicTitle = Artist End If Else ' Se há título válido If IsValidTitle Then ' Retorna apenas título da faixa MusicTitle = Title Else ' Retorna endereço do arquivo MusicTitle = FileAddress End If End If End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Procedimentos de criação e destruição do objeto ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub Class_Initialize() ' Inicia valores st_Title = ST_INVALID_VALUE st_Artist = ST_INVALID_VALUE st_Album = ST_INVALID_VALUE ln_Duration = LN_INVALID_VALUE ln_ID = LN_INVALID_VALUE st_FileAddress = ST_INVALID_VALUE ln_FileSize = LN_NO_ADDRESS End Sub