VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsFilesFilterList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' -------------------------------------------------------------------------------------------
'
'   AVStoDVD - by MrC
'   File: clsFilesFilterList.cls
'   Purpose: Class that generates video/audio/subs filter list for use with common dialogs
'
' -------------------------------------------------------------------------------------------




Option Explicit
Option Compare Binary
Option Base 0


Private VideoFilesList As String
Private VideoFilesFilter As String
Private VideoMPEG2FilesFilter As String
Private VideoContainerFilesList As String
Private VideoContainerFilesFilter As String
Private AudioFilesFilter As String
Private SubsFilesFilter As String


Private Sub Class_Initialize()

    Dim VideoFilesDescription As New Collection
    Dim VideoFilesExtensions As New Collection
    Dim VideoMPEG2FilesDescription As New Collection
    Dim VideoMPEG2FilesExtensions As New Collection
    Dim VideoContainerFilesDescription As New Collection
    Dim VideoContainerFilesExtensions As New Collection
    Dim AudioFilesDescription As New Collection
    Dim AudioFilesExtensions As New Collection
    Dim SubsFilesDescription As New Collection
    Dim SubsFilesExtensions As New Collection
    Dim jj As Integer
    
    With VideoFilesDescription
        .add "3GPP files", "1"
        .add "AVI files", "2"
        .add "DivX files", "3"
        .add "Flash Video files", "4"
        .add "Matroska Video files", "5"
        .add "Motion-JPEG Video files", "6"
        .add "MPEG1 files", "7"
        .add "MPEG2 files", "8"
        .add "MPEG4 files", "9"
        .add "MPEG Transport Stream files", "10"
        .add "QuickTime files", "11"
        .add "RealMedia files", "12"
        .add "Vorbis files", "13"
        .add "Windows Media Video files", "14"
        .add "AviSynth Script files", "15"
        .add "DGIndex Project files", "16"
        .add "DVD VTS Info files", "17"
    End With
    With VideoFilesExtensions
        .add "*.3gp;*.3g2", "1"
        .add "*.avi", "2"
        .add "*.divx", "3"
        .add "*.flv;*.f4v", "4"
        .add "*.mkv", "5"
        .add "*.mjpg;*.mjpeg", "6"
        .add "*.mpg;*.mpeg;*.m1v", "7"
        .add "*.mpg;*.mpeg;*.m2v;*.mpv;*.vob", "8"
        .add "*.mp4;*.m4v", "9"
        .add "*.ts;*.mts;*.m2ts", "10"
        .add "*.qt;*.mov;*.hdmov", "11"
        .add "*.rm", "12"
        .add "*.ogm", "13"
        .add "*.wmv;*.asf", "14"
        .add "*.avs", "15"
        .add "*.d2v", "16"
        .add "VTS*.ifo", "17"
    End With
    For jj = 1 To VideoFilesDescription.Count
        VideoFilesList = VideoFilesList & VideoFilesDescription.Item(jj) & " (" & VideoFilesExtensions.Item(jj) & ")" & vbCrLf
    Next jj
    VideoFilesFilter = coll2str(VideoFilesDescription, VideoFilesExtensions)
    
    With VideoMPEG2FilesDescription
        .add "MPEG1 files", "1"
        .add "MPEG2 files", "2"
        .add "MPEG Transport Stream files", "3"
    End With
    With VideoMPEG2FilesExtensions
        .add "*.mpg;*.mpeg;*.m1v", "1"
        .add "*.mpg;*.mpeg;*.m2v;*.mpv;*.vob", "2"
        .add "*.ts;*.mts;*.m2ts", "3"
    End With
    VideoMPEG2FilesFilter = coll2str(VideoMPEG2FilesDescription, VideoMPEG2FilesExtensions)
    
    With VideoContainerFilesDescription
        .add "3GPP files", "1"
        .add "AVI files", "2"
        .add "Flash Video files", "3"
        .add "Matroska Video files", "4"
        .add "MPEG1 files", "5"
        .add "MPEG2 files", "6"
        .add "MPEG4 files", "7"
        .add "MPEG Transport Stream files", "8"
        .add "QuickTime files", "9"
        .add "RealMedia files", "10"
        .add "Windows Media Video files", "11"
    End With
    With VideoContainerFilesExtensions
        .add "*.3gp;*.3g2", "1"
        .add "*.avi", "2"
        .add "*.flv;*.f4v", "3"
        .add "*.mkv", "4"
        .add "*.mpg;*.mpeg;*.m1v", "5"
        .add "*.mpg;*.mpeg;*.m2v;*.mpv;*.vob", "6"
        .add "*.mp4;*.m4v", "7"
        .add "*.ts;*.mts;*.m2ts", "8"
        .add "*.qt;*.mov;*.hdmov", "9"
        .add "*.rm", "10"
        .add "*.wmv;*.asf", "11"
    End With
    For jj = 1 To VideoContainerFilesDescription.Count
        VideoContainerFilesList = VideoContainerFilesList & VideoContainerFilesDescription.Item(jj) & " (" & VideoContainerFilesExtensions.Item(jj) & ")" & vbCrLf
    Next jj
    VideoContainerFilesFilter = coll2str(VideoContainerFilesDescription, VideoContainerFilesExtensions)
    
    Set AudioFilesDescription = VideoFilesDescription
    With AudioFilesDescription
        .add "Advanced Audio Coding files", "18"
        .add "Dolby AC3 files", "19"
        .add "Adaptive Multi-Rate files", "20"
        .add "Digital DTS files", "21"
        .add "FLAC Audio files", "22"
        .add "Matroska Audio files", "23"
        .add "MPEG1 Layer 2 Audio files", "24"
        .add "MPEG1 Layer 3 Audio files", "25"
        .add "MPEG4 Part 14 Audio files", "26"
        .add "OGG Vorbis files", "27"
        .add "PCM WAV files", "28"
        .add "Windows Media Audio files", "29"
    End With
    Set AudioFilesExtensions = VideoFilesExtensions
    With AudioFilesExtensions
        .add "*.aac", "18"
        .add "*.ac3", "19"
        .add "*.amr", "20"
        .add "*.dts", "21"
        .add "*.flac", "22"
        .add "*.mka", "23"
        .add "*.mp2;*.mpa", "24"
        .add "*.mp3", "25"
        .add "*.mp4;*.m4a", "26"
        .add "*.ogg", "27"
        .add "*.wav", "28"
        .add "*.wma", "29"
    End With
    AudioFilesFilter = coll2str(AudioFilesDescription, AudioFilesExtensions)
    
    With SubsFilesDescription
        .add "SubRip Text-Based File", "1"
        .add "IfoEdit Subpicture File", "2"
        .add "Scenarist Sub Script", "3"
        .add "VobSub idx/sub File", "4"
        .add "SubStation Alpha File", "5"
        .add "MicroDVD File", "6"
    End With
    With SubsFilesExtensions
        .add "*.srt", "1"
        .add "*.sup", "2"
        .add "*.sst", "3"
        .add "*.idx", "4"
        .add "*.ssa;*.ass", "5"
        .add "*.sub;*.txt", "6"
    End With
    SubsFilesFilter = coll2str(SubsFilesDescription, SubsFilesExtensions)
    
    Set VideoFilesDescription = Nothing
    Set VideoFilesExtensions = Nothing
    Set AudioFilesDescription = Nothing
    Set AudioFilesExtensions = Nothing
    Set SubsFilesDescription = Nothing
    Set SubsFilesExtensions = Nothing

End Sub

Private Function coll2str(collDescr As Collection, collExts As Collection) As String

    Dim jj As Integer
    
    coll2str = "All supported types|"
    For jj = 1 To collDescr.Count
        coll2str = coll2str & collExts.Item(jj) & ";"
    Next jj
    coll2str = Left(coll2str, Len(coll2str) - 1) & "|"
    For jj = 1 To collDescr.Count
        coll2str = coll2str & collDescr.Item(jj) & " (" & collExts.Item(jj) & ")|" & collExts.Item(jj) & "|"
    Next jj

End Function

Public Property Get SupportedVideoFormats() As String

    SupportedVideoFormats = VideoFilesList
    
End Property

Public Property Get VideoFiles(Optional NoAllFiles As Boolean) As String

    VideoFiles = VideoFilesFilter
    If NoAllFiles = False Then
        VideoFiles = VideoFiles & "All files (*.*)|*.*"
    End If
    
End Property

Public Property Get VideoMPEG2Files(Optional NoAllFiles As Boolean) As String

    VideoMPEG2Files = VideoMPEG2FilesFilter
    If NoAllFiles = False Then
        VideoMPEG2Files = VideoMPEG2Files & "All files (*.*)|*.*"
    End If
    
End Property

Public Property Get SupportedVideoContainerFormats() As String

    SupportedVideoContainerFormats = VideoContainerFilesList
    
End Property

Public Property Get VideoContainerFiles(Optional NoAllFiles As Boolean) As String

    VideoContainerFiles = VideoContainerFilesFilter
    If NoAllFiles = False Then
        VideoContainerFiles = VideoContainerFiles & "All files (*.*)|*.*"
    End If
    
End Property

Public Property Get AudioFiles(Optional NoAllFiles As Boolean) As String

    AudioFiles = AudioFilesFilter
    If NoAllFiles = False Then
        AudioFiles = AudioFiles & "All files (*.*)|*.*"
    End If
    
End Property

Public Property Get SubsFiles(Optional NoAllFiles As Boolean) As String

    SubsFiles = SubsFilesFilter
    If NoAllFiles = False Then
        SubsFiles = SubsFiles & "All files (*.*)|*.*"
    End If
    
End Property


