home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 November / Chip_2002-11_cd1.bin / zkuste / vbasic / Data / Utils / WME71SDK.exe / RCDATA / CABINET / frmstationmanager.frm < prev    next >
Text File  |  2001-04-17  |  29KB  |  1,097 lines

  1. VERSION 5.00
  2. Object = "{C4941F47-8BC1-49D3-9989-2B7826F26AE6}#1.0#0"; "MSPShell.dll"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form frmStationManager 
  5.    Caption         =   "Windows Media Station Manager Sample"
  6.    ClientHeight    =   5760
  7.    ClientLeft      =   1350
  8.    ClientTop       =   1725
  9.    ClientWidth     =   9645
  10.    Icon            =   "frmStationManager.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5760
  13.    ScaleWidth      =   9645
  14.    Begin MSPROPSHELLLibCtl.MSPropShell StationStat 
  15.       Height          =   3255
  16.       Left            =   0
  17.       OleObjectBlob   =   "frmStationManager.frx":000C
  18.       TabIndex        =   8
  19.       Top             =   2400
  20.       Width           =   8295
  21.    End
  22.    Begin VB.Timer tmrStn 
  23.       Enabled         =   0   'False
  24.       Interval        =   1000
  25.       Left            =   8640
  26.       Top             =   2160
  27.    End
  28.    Begin VB.CommandButton cmdExit 
  29.       Cancel          =   -1  'True
  30.       Caption         =   "E&xit"
  31.       Height          =   375
  32.       Left            =   8400
  33.       TabIndex        =   7
  34.       Top             =   3600
  35.       Width           =   1215
  36.    End
  37.    Begin VB.CommandButton cmdStop 
  38.       Caption         =   "S&top"
  39.       Height          =   375
  40.       Left            =   8400
  41.       TabIndex        =   6
  42.       Top             =   3120
  43.       Width           =   1215
  44.    End
  45.    Begin VB.CommandButton cmdStart 
  46.       Caption         =   "&Start"
  47.       Height          =   375
  48.       Left            =   8400
  49.       TabIndex        =   5
  50.       Top             =   2640
  51.       Width           =   1215
  52.    End
  53.    Begin VB.CommandButton cmdPlaylist 
  54.       Caption         =   "&Playlist..."
  55.       Default         =   -1  'True
  56.       Height          =   375
  57.       Left            =   8400
  58.       TabIndex        =   4
  59.       Top             =   1560
  60.       Width           =   1215
  61.    End
  62.    Begin VB.CommandButton cmdRemove 
  63.       Caption         =   "&Remove"
  64.       Height          =   375
  65.       Left            =   8400
  66.       TabIndex        =   3
  67.       Top             =   1080
  68.       Width           =   1215
  69.    End
  70.    Begin VB.CommandButton cmdChange 
  71.       Caption         =   "&Change..."
  72.       Height          =   375
  73.       Left            =   8400
  74.       TabIndex        =   2
  75.       Top             =   600
  76.       Width           =   1215
  77.    End
  78.    Begin VB.CommandButton cmdAdd 
  79.       Caption         =   "&New Station..."
  80.       Height          =   375
  81.       Left            =   8400
  82.       TabIndex        =   1
  83.       Top             =   120
  84.       Width           =   1215
  85.    End
  86.    Begin MSComctlLib.ListView lvwStation 
  87.       Height          =   2175
  88.       Left            =   0
  89.       TabIndex        =   0
  90.       Top             =   120
  91.       Width           =   8295
  92.       _ExtentX        =   14631
  93.       _ExtentY        =   3836
  94.       View            =   3
  95.       LabelEdit       =   1
  96.       LabelWrap       =   -1  'True
  97.       HideSelection   =   -1  'True
  98.       _Version        =   393217
  99.       ForeColor       =   -2147483640
  100.       BackColor       =   -2147483643
  101.       BorderStyle     =   1
  102.       Appearance      =   1
  103.       NumItems        =   4
  104.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  105.          Key             =   "Name"
  106.          Text            =   "Name"
  107.          Object.Width           =   2540
  108.       EndProperty
  109.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  110.          SubItemIndex    =   1
  111.          Key             =   "Playlist"
  112.          Text            =   "Playlist"
  113.          Object.Width           =   2540
  114.       EndProperty
  115.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  116.          SubItemIndex    =   2
  117.          Key             =   "Status"
  118.          Text            =   "Status"
  119.          Object.Width           =   2540
  120.       EndProperty
  121.       BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  122.          SubItemIndex    =   3
  123.          Key             =   "URL"
  124.          Text            =   "URL"
  125.          Object.Width           =   2540
  126.       EndProperty
  127.    End
  128. End
  129. Attribute VB_Name = "frmStationManager"
  130. Attribute VB_GlobalNameSpace = False
  131. Attribute VB_Creatable = False
  132. Attribute VB_PredeclaredId = True
  133. Attribute VB_Exposed = False
  134. Option Explicit
  135. Public StnCol As New Collection
  136. Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nsize As Long) As Long
  137.  
  138. Private Sub cmdAdd_Click()
  139.     
  140.     On Error GoTo error_handler
  141.     
  142.     Dim EncoderStn As New StnMgrEnc
  143.     
  144.     Dim Success As Boolean
  145.     
  146.     Dim EncoderName As String
  147.     
  148.     EncoderStn.EncInit
  149.     
  150.     Set frmNewStation.StationMgrEnc = EncoderStn
  151.    
  152.     frmNewStation.Show 1
  153.     
  154.     EncoderName = EncoderStn.EncName
  155.     
  156.     If EncoderName = "" Then
  157.         
  158.         Set EncoderStn = Nothing
  159.         
  160.         Exit Sub
  161.     
  162.     End If
  163.     
  164.     StnCol.Add EncoderStn, EncoderName
  165.     
  166.     Populate_list (EncoderName)
  167.     
  168.     cmdChange.Enabled = True
  169.     
  170.     cmdRemove.Enabled = True
  171.     
  172.     cmdPlaylist.Enabled = True
  173.     
  174.     cmdStart.Enabled = True
  175.     
  176.     cmdStop.Enabled = True
  177.     
  178.     Exit Sub
  179.     
  180. error_handler:
  181.     MsgBox "Error Adding New Station", vbCritical
  182.     
  183. End Sub
  184.  
  185. Private Sub cmdChange_Click()
  186.     
  187.     On Error GoTo error_handler
  188.     
  189.     
  190.     Dim SelItem As String
  191.     
  192.     Dim StnCls As StnMgrEnc
  193.     Dim EncName As String
  194.     
  195.     
  196.  
  197.     
  198.     
  199.     SelItem = lvwStation.SelectedItem.Text
  200.     
  201.     Set StnCls = StnCol(SelItem)
  202.     
  203.     EncName = StnCls.EncName
  204.     
  205.     Set frmNewStation.StationMgrEnc = StnCls
  206.     
  207.     frmNewStation.txtName.Text = EncName
  208.     frmNewStation.optAudio.Enabled = False
  209.     frmNewStation.optVideo.Enabled = False
  210.     
  211.     frmNewStation.Show 1
  212.     
  213.     
  214.     EncName = StnCls.EncName
  215.     
  216.     If lvwStation.SelectedItem.Text <> EncName Then
  217.     
  218.         lvwStation.SelectedItem.Text = EncName
  219.         
  220.         StnCol.Remove SelItem
  221.     
  222.         StnCol.Add StnCls, EncName
  223.     End If
  224.     
  225.     Exit Sub
  226.     
  227. error_handler:
  228.     
  229.     MsgBox "Error Changing the properties of the station", vbCritical
  230.     
  231. End Sub
  232.  
  233. Private Sub cmdExit_Click()
  234.     
  235.     Unload Me
  236.     
  237.     End
  238.     
  239. End Sub
  240.  
  241. Private Sub cmdPlaylist_Click()
  242.     
  243.     On Error GoTo error_handler
  244.     
  245.     Dim Name As String
  246.     Dim StnPlay As StnMgrEnc
  247.     
  248.     
  249.     
  250.     Name = lvwStation.SelectedItem.Text
  251.     
  252.     
  253.     Set StnPlay = StnCol.Item(Name)
  254.     
  255.     Set frmPlaylist.StnMgr = StnPlay
  256.     
  257.     frmPlaylist.Caption = "Playlist for Station" & Name
  258.     
  259.     frmPlaylist.Show 1
  260.     
  261.     Exit Sub
  262.     
  263. error_handler:
  264.     
  265.     MsgBox "Error Reteriving The playlist For the Station", vbCritical
  266.     
  267. End Sub
  268.  
  269. Private Sub cmdRemove_Click()
  270.     
  271.     On Error GoTo error_handler
  272.     
  273.     Dim SelItem As String
  274.     
  275.     If lvwStation.ListItems.Count = 0 Then
  276.         
  277.         Exit Sub
  278.     
  279.     End If
  280.         
  281.     SelItem = lvwStation.SelectedItem.Text
  282.     
  283.     StnCol.Remove (SelItem)
  284.     
  285.     lvwStation.ListItems.Remove lvwStation.SelectedItem.Index
  286.     
  287.     If lvwStation.ListItems.Count = 0 Then
  288.         
  289.         cmdChange.Enabled = False
  290.         
  291.         cmdRemove.Enabled = False
  292.         
  293.         cmdPlaylist.Enabled = False
  294.         
  295.         cmdStart.Enabled = False
  296.         
  297.         cmdStop.Enabled = False
  298.     
  299.     End If
  300.     
  301.     Exit Sub
  302.     
  303. error_handler:
  304.     MsgBox "Error Removing From The List", vbExclamation
  305.     
  306.     
  307. End Sub
  308.  
  309. Private Sub cmdStart_Click()
  310.     On Error GoTo error_handler
  311.     
  312.     Dim SelItem As String
  313.     
  314.     Dim Enc As WMEncoder
  315.     Dim StnCls As New StnMgrEnc
  316.     
  317.     Dim MaxCnt As Integer
  318.     Dim PlayCnt As Integer
  319.     
  320.     
  321.     Dim PrfCol As IWMEncProfileCollection
  322.     
  323.     
  324.     Dim prf As IWMEncProfile
  325.     Dim PrfName As String
  326.     
  327.     
  328.     Dim SrcGrpCol As IWMEncSourceGroupCollection
  329.     
  330.     Dim SrcGrpCurr As IWMEncSourceGroup
  331.     
  332.     Dim SrcGrpNext As IWMEncSourceGroup
  333.     
  334.     
  335.     Dim PpgMain As New WMEncMonMainPage
  336.     
  337.     If lvwStation.SelectedItem.ListSubItems.Item("Playlist") = "0 Items" Then
  338.         MsgBox "Please Add Items In the play List", vbCritical, "Error- Starting"
  339.         Exit Sub
  340.     End If
  341.     
  342.     If lvwStation.SelectedItem.ListSubItems.Item("Status") = "Running" Then
  343.         MsgBox "The Station Has Already Been started", vbExclamation, "Error- Starting"
  344.         Exit Sub
  345.     End If
  346.         
  347.     
  348.     SelItem = lvwStation.SelectedItem.Text
  349.     
  350.     Set StnCls = StnCol.Item(SelItem)
  351.     
  352.     Set Enc = StnCls.ExistEnc
  353.     
  354.     Set SrcGrpCol = Enc.SourceGroupCollection
  355.     
  356.     Set SrcGrpCurr = SrcGrpCol.Add("Current")
  357.         
  358.     Process_SrcGrp SelItem, SrcGrpCurr
  359.     
  360.     PrfName = StnCls.EncPrfName
  361.     
  362.     Set PrfCol = Enc.ProfileCollection
  363.     
  364.     
  365.     If StnCls.LstStop = 0 Then
  366.     
  367.         For Each prf In PrfCol
  368.             
  369.             If UCase(prf.Name) = UCase(PrfName) Then
  370.                 
  371.                 SrcGrpCurr.Profile = prf
  372.                 
  373.                 Exit For
  374.             
  375.             End If
  376.         
  377.         Next
  378.     
  379.     End If
  380.     
  381.     
  382.     SrcGrpCol.Active = SrcGrpCurr
  383.     
  384.     PlayCnt = StnCls.PlaylistPos
  385.     
  386.     PlayCnt = PlayCnt + 1
  387.     
  388.     StnCls.PlaylistPos = PlayCnt
  389.     
  390.     MaxCnt = StnCls.MaxBound
  391.     
  392.     If MaxCnt > 1 And MaxCnt <> PlayCnt Then
  393.      
  394.         Set SrcGrpNext = SrcGrpCol.Add("Next")
  395.         
  396.         
  397.         Process_SrcGrp SelItem, SrcGrpNext
  398.         
  399.         If StnCls.LstStop = 0 Then
  400.         
  401.             For Each prf In PrfCol
  402.                 
  403.                 If UCase(prf.Name) = UCase(PrfName) Then
  404.                     
  405.                     SrcGrpNext.Profile = prf
  406.                     
  407.                     Exit For
  408.                 
  409.                 End If
  410.             
  411.             Next
  412.         
  413.         End If
  414.         
  415.     Else
  416.         
  417.         StnCls.LstStop = 1
  418.     
  419.     End If
  420.     
  421.     Enc.AutoStop = False
  422.     
  423.     StationStat.AddObject Enc
  424.     
  425.     StationStat.AddPage PpgMain
  426.     
  427.     
  428.     
  429.     Enc.Start
  430.     
  431.     lvwStation.SelectedItem.ListSubItems.Item("Playlist").Text = PlayCnt & " of " & MaxCnt & " items"
  432.     
  433.     If Enc.RunState = WMENC_ENCODER_RUNNING Then
  434.          
  435.          lvwStation.SelectedItem.ListSubItems.Item("Status") = "Running"
  436.          
  437.          cmdChange.Enabled = False
  438.          cmdRemove.Enabled = False
  439.          
  440.     End If
  441.     
  442.     tmrStn.Enabled = True
  443.     
  444.     Exit Sub
  445.     
  446. error_handler:
  447.     
  448.     MsgBox "Error Starting The Station", vbCritical
  449. End Sub
  450.  
  451. Private Sub cmdStop_Click()
  452.     
  453.     On Error GoTo error_handler
  454.     
  455.     Dim SelItem As String
  456.     Dim MaxCnt As Integer
  457.     
  458.     Dim Encoder As WMEncoder
  459.     Dim StnCls As StnMgrEnc
  460.     
  461.     
  462.     Dim SrcGrpCol As IWMEncSourceGroupCollection
  463.     
  464.     If lvwStation.SelectedItem.ListSubItems.Item("Status") = "Stopped" Then
  465.         MsgBox "Station Already stopped", vbExclamation
  466.         Exit Sub
  467.     End If
  468.     
  469.     SelItem = lvwStation.SelectedItem.Text
  470.     
  471.     Set StnCls = StnCol(SelItem)
  472.     
  473.     Set Encoder = StnCls.ExistEnc
  474.     
  475.     MaxCnt = StnCls.MaxBound
  476.     
  477.     Encoder.Stop
  478.     
  479.     StnCls.Stat = 0
  480.     
  481.     Set SrcGrpCol = Encoder.SourceGroupCollection
  482.             
  483.     If MaxCnt > 1 Then
  484.         
  485.         SrcGrpCol.Remove (0)
  486.         
  487.         SrcGrpCol.Remove (0)
  488.     
  489.     Else
  490.         
  491.         SrcGrpCol.Remove (0)
  492.     
  493.     End If
  494.     
  495.     lvwStation.SelectedItem.ListSubItems.Item("Status") = "Stopped"
  496.     
  497.     tmrStn.Enabled = False
  498.     
  499.     cmdChange.Enabled = True
  500.     cmdRemove.Enabled = True
  501.     
  502.     Exit Sub
  503.     
  504. error_handler:
  505.     MsgBox "Error Stopping The Station", vbCritical
  506.     
  507.     
  508. End Sub
  509.  
  510. Private Sub Form_Load()
  511.     On Error GoTo error_handler
  512.     
  513.     Dim I As Integer
  514.     
  515.     Dim StnCls As New StnMgrEnc
  516.     
  517.     For I = 1 To 4
  518.         lvwStation.ColumnHeaders.Item(I).Width = lvwStation.Width / 4
  519.     Next
  520.     
  521.     If lvwStation.ListItems.Count = 0 Then
  522.         cmdChange.Enabled = False
  523.         cmdRemove.Enabled = False
  524.         cmdPlaylist.Enabled = False
  525.         cmdStart.Enabled = False
  526.         cmdStop.Enabled = False
  527.     End If
  528.     
  529.     Exit Sub
  530.     
  531. error_handler:
  532.     MsgBox "Error Starting The Station Manager", vbCritical
  533.     End
  534.     
  535. End Sub
  536.  
  537. Function Populate_list(EncName As String) As Boolean
  538.     
  539.     On Error GoTo error_handler
  540.     
  541.     Dim Cnt As Integer
  542.     
  543.     Dim CmpName As String
  544.     Dim Ret As Long
  545.     Dim Prt As Long
  546.     
  547.     Dim Prt1 As String
  548.     Dim StnEnc As StnMgrEnc
  549.     Dim Enc As WMEncoder
  550.     Dim Brdcst As IWMEncBroadcast
  551.     
  552.     For Each StnEnc In StnCol
  553.         If StnEnc.EncName = EncName Then
  554.             Set Enc = StnEnc.ExistEnc
  555.             Exit For
  556.         End If
  557.      Next
  558.      
  559.     Set Brdcst = Enc.Broadcast
  560.     
  561.     Prt = Brdcst.PortNumber(WMENC_PROTOCOL_HTTP)
  562.     
  563.     Prt1 = CStr(Prt)
  564.     
  565.     CmpName = "unknown"
  566.     
  567.     Cnt = lvwStation.ListItems.Count + 1
  568.     
  569.     Ret = GetComputerName(CmpName, 20)
  570.     
  571.     Trim (CmpName)
  572.     
  573.     CmpName = CmpName & ":" & Prt1
  574.     
  575.     CmpName = "http://" & CmpName
  576.     
  577.     lvwStation.ListItems.Add Cnt, , EncName
  578.     
  579.     lvwStation.ListItems(Cnt).ListSubItems.Add , "Playlist", "0 Items"
  580.       
  581.     lvwStation.ListItems(Cnt).ListSubItems.Add , "Status", "Stopped"
  582.     
  583.     lvwStation.ListItems(Cnt).ListSubItems.Add , "URL", CmpName
  584.     
  585.     
  586.     lvwStation.FullRowSelect = True
  587.     
  588.     Set lvwStation.SelectedItem = lvwStation.ListItems(1)
  589.     
  590.     Set lvwStation.DropHighlight = lvwStation.ListItems(1)
  591.     
  592.     Exit Function
  593.     
  594. error_handler:
  595.     
  596.     MsgBox "Error Adding The Station To The List", vbCritical
  597.     
  598. End Function
  599. Private Sub lvwStation_Click()
  600.     
  601.     On Error GoTo error_handler
  602.     
  603.     Dim PpgMain As New WMEncMonMainPage
  604.     
  605.     Dim SelItem As String
  606.     
  607.     Dim StnCls As StnMgrEnc
  608.     
  609.     Dim Enc As WMEncoder
  610.     
  611.     Set lvwStation.DropHighlight = lvwStation.SelectedItem
  612.     
  613.     lvwStation.FullRowSelect = True
  614.     
  615.     If lvwStation.SelectedItem.ListSubItems.Item("Status") = "Running" Then
  616.         
  617.         SelItem = lvwStation.SelectedItem.Text
  618.         
  619.         Set StnCls = StnCol(SelItem)
  620.         
  621.         Set Enc = StnCls.ExistEnc
  622.             
  623.         StationStat.AddPage PpgMain
  624.         
  625.         StationStat.AddObject Enc
  626.         
  627.     Else
  628.     
  629.         cmdChange.Enabled = True
  630.         cmdRemove.Enabled = True
  631.         
  632.     End If
  633.         
  634.     Exit Sub
  635.     
  636. error_handler:
  637.     MsgBox "Error Selecting The required Station"
  638. End Sub
  639.  
  640.  
  641. Public Sub Process_SrcGrp(SelItem As String, SrcGrp As IWMEncSourceGroup)
  642.     On Error GoTo error_handler
  643.     
  644.     Dim ProcStn As StnMgrEnc
  645.         
  646.     Dim Cnt As Integer
  647.     Dim FileInAud As String
  648.     Dim FileInVid As String
  649.     Dim Dur As String
  650.     Dim UpLimit As Integer
  651.     Dim pos As Integer
  652.     
  653.     Dim AudSrc As IWMEncSource
  654.     Dim VidSrc As IWMEncSource
  655.     
  656.     
  657.     Set ProcStn = StnCol.Item(SelItem)
  658.     
  659.     pos = ProcStn.PlaylistPos
  660.     
  661.     UpLimit = ProcStn.MaxBound
  662.     
  663.     If pos >= UpLimit Then
  664.          
  665.          ProcStn.LstStop = 1
  666.          
  667.          Exit Sub
  668.     
  669.     End If
  670.     
  671.     pos = pos + 1
  672.     
  673.     ProcStn.AllElem FileInVid, FileInAud, Dur, pos
  674.     
  675.     If ProcStn.VideoOpt = 0 Then
  676.         
  677.         Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
  678.         
  679.         If Dur = "-" Then
  680.             FileInAud = "FILE://" & FileInAud
  681.             AudSrc.SetInput FileInAud
  682.         
  683.         Else
  684.         
  685.             AudSrc.SetInput FileInAud
  686.         End If
  687.         
  688.     Else
  689.         
  690.         Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
  691.         
  692.         Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)
  693.         
  694.         If Dur = "-" Then
  695.             
  696.             FileInAud = "FILE://" & FileInAud
  697.             
  698.             FileInVid = "FILE://" & FileInVid
  699.             
  700.             AudSrc.SetInput FileInAud
  701.             
  702.             VidSrc.SetInput FileInVid
  703.         Else
  704.          
  705.             FileInAud = "DEVICE://" & FileInAud
  706.             
  707.             If FileInVid = "Screen Capture" Then
  708.                 FileInVid = "ScreenCap://"
  709.             Else
  710.                 FileInVid = "DEVICE://" & FileInVid
  711.             End If
  712.  
  713.             AudSrc.SetInput FileInAud
  714.             
  715.             VidSrc.SetInput FileInVid
  716.         End If
  717.         
  718.     End If
  719.     
  720.     Exit Sub
  721.     
  722. error_handler:
  723.     
  724.     MsgBox "Error In Assigning Sourcegroups", vbCritical
  725.         
  726. End Sub
  727.  
  728. Private Sub tmrStn_Timer()
  729.     
  730.     On Error GoTo error_handler
  731.     
  732.     Dim StnTmr As StnMgrEnc
  733.     
  734.     Dim Cnt As Integer
  735.     Dim MaxCnt As Integer
  736.     
  737.     Dim I As Integer
  738.     Dim SelItem As String
  739.     
  740.     Dim PlayCnt As Integer
  741.     
  742.     Dim FileInAud As String
  743.     Dim FileInVid As String
  744.     Dim Dur As String
  745.     
  746.     Dim SrcGrp As IWMEncSourceGroup
  747.     Dim SrcGrpN As IWMEncSourceGroup
  748.     Dim SrcGrpCol As IWMEncSourceGroupCollection
  749.     Dim AudioSrc As IWMEncSource
  750.     Dim VideoSrc As IWMEncSource
  751.     
  752.     Dim Enc As WMEncoder
  753.     
  754.     
  755.     
  756.     Cnt = lvwStation.ListItems.Count
  757.     
  758.     For I = 1 To Cnt
  759.         If lvwStation.ListItems(I).ListSubItems.Item("Status") = "Running" Then
  760.             
  761.             SelItem = lvwStation.ListItems.Item(I).Text
  762.             
  763.             Set StnTmr = StnCol.Item(SelItem)
  764.             
  765.             PlayCnt = StnTmr.PlaylistPos
  766.             
  767.             MaxCnt = StnTmr.MaxBound
  768.             
  769.             StnTmr.PlayElem FileInVid, FileInAud, Dur
  770.              
  771.             If Dur = "-" And StnTmr.Stat = 1 And StnTmr.LstStop = 1 Then
  772.                
  773.                lvwStation.ListItems(I).ListSubItems.Item("Status") = "Stopped"
  774.                
  775.                StnTmr.PlaylistPos = 0
  776.                
  777.                Set Enc = StnTmr.ExistEnc
  778.                
  779.                Set SrcGrpCol = Enc.SourceGroupCollection
  780.                
  781.                Enc.Stop
  782.                
  783.                StnTmr.LstStop = 0
  784.                
  785.                StnTmr.Stat = 0
  786.                
  787.                If MaxCnt > 1 Then
  788.                   
  789.                   SrcGrpCol.Remove (0)
  790.                   
  791.                   SrcGrpCol.Remove (0)
  792.                
  793.                Else
  794.                   
  795.                   SrcGrpCol.Remove (0)
  796.                
  797.                End If
  798.                
  799.                cmdChange.Enabled = True
  800.                cmdRemove.Enabled = True
  801.                
  802.             End If
  803.             
  804.             If Dur = "-" And StnTmr.Stat = 1 And StnTmr.LstStop <> 1 Then
  805.                 
  806.                 Set Enc = StnTmr.ExistEnc
  807.                 
  808.                 Set SrcGrpCol = Enc.SourceGroupCollection
  809.                 
  810.                 Set SrcGrp = SrcGrpCol.Active
  811.                 
  812.                 If SrcGrp.Name = "Current" Then
  813.                                       
  814.                     For Each SrcGrpN In SrcGrpCol
  815.                         
  816.                         If SrcGrpN.Name = "Next" Then
  817.                             
  818.                             StnTmr.Stat = 0
  819.                             
  820.                             PlayCnt = PlayCnt + 1
  821.                             
  822.                             StnTmr.PlaylistPos = PlayCnt
  823.                             
  824.                             lvwStation.ListItems(I).ListSubItems.Item("Playlist").Text = PlayCnt & " of " & MaxCnt & " items"
  825.                             
  826.                             SrcGrpCol.Active = SrcGrpN
  827.                             
  828.                             Enc.Start
  829.                                                         
  830.                             Exit For
  831.                         End If
  832.                       
  833.                     Next
  834.                     
  835.                     If StnTmr.VideoOpt = 0 Then
  836.                                                 
  837.                         NewInput SrcGrp, 0, SelItem
  838.                                                     
  839.                     Else
  840.                         
  841.                         NewInput SrcGrp, 1, SelItem
  842.                                                 
  843.                     End If
  844.                     
  845.                     
  846.                 Else
  847.                 
  848.                     
  849.                     
  850.                     For Each SrcGrpN In SrcGrpCol
  851.                     
  852.                         If SrcGrpN.Name = "Current" Then
  853.                         
  854.                             StnTmr.Stat = 0
  855.                             
  856.                             PlayCnt = PlayCnt + 1
  857.                             
  858.                             StnTmr.PlaylistPos = PlayCnt
  859.                             
  860.                             lvwStation.ListItems(I).ListSubItems.Item("Playlist").Text = PlayCnt & " of " & MaxCnt & " items"
  861.                             
  862.                             SrcGrpCol.Active = SrcGrpN
  863.                             
  864.                             Enc.Start
  865.                                                         
  866.                             Exit For
  867.                             
  868.                         End If
  869.                         
  870.                     Next
  871.                     If StnTmr.VideoOpt = 0 Then
  872.                         
  873.                         NewInput SrcGrp, 0, SelItem
  874.                                                 
  875.                     Else
  876.                         
  877.                         NewInput SrcGrp, 1, SelItem
  878.                                                                       
  879.                     End If
  880.                     
  881.                 
  882.                 End If
  883.                                 
  884.             End If
  885.             
  886.             If Dur = "0" And StnTmr.LstStop = 1 Then
  887.                 
  888.                 lvwStation.ListItems(I).ListSubItems.Item("Status") = "Stopped"
  889.                 
  890.                 StnTmr.PlaylistPos = 0
  891.                
  892.                 Set Enc = StnTmr.ExistEnc
  893.                
  894.                 Set SrcGrpCol = Enc.SourceGroupCollection
  895.                
  896.                 Enc.Stop
  897.                  
  898.                 StnTmr.LstStop = 0
  899.                
  900.                 StnTmr.Stat = 0
  901.                 
  902.                 If MaxCnt > 1 Then
  903.                     
  904.                     SrcGrpCol.Remove (0)
  905.                     
  906.                     SrcGrpCol.Remove (0)
  907.                     
  908.                 Else
  909.                     
  910.                     SrcGrpCol.Remove (0)
  911.                     
  912.                 End If
  913.                 
  914.                 cmdChange.Enabled = True
  915.                 cmdRemove.Enabled = True
  916.                 
  917.             Else  'replaced "End If" here
  918.             
  919.                 If Dur = "0" And StnTmr.LstStop <> 1 Then
  920.                     
  921.                     Set Enc = StnTmr.ExistEnc
  922.                     
  923.                     Set SrcGrpCol = Enc.SourceGroupCollection
  924.                     
  925.                     Set SrcGrp = SrcGrpCol.Active
  926.                     
  927.                     If SrcGrp.Name = "Current" Then
  928.                         
  929.                         
  930.                         For Each SrcGrpN In SrcGrpCol
  931.                             
  932.                             If SrcGrpN.Name = "Next" Then
  933.                              
  934.                                 
  935.                                 PlayCnt = PlayCnt + 1
  936.                                 
  937.                                 StnTmr.PlaylistPos = PlayCnt
  938.                                 
  939.                                 lvwStation.ListItems(I).ListSubItems.Item("Playlist").Text = PlayCnt & " of " & MaxCnt & " items"
  940.                                 
  941.                                 SrcGrpCol.Active = SrcGrpN
  942.                                 
  943.                                 Enc.Start
  944.                                 
  945.                                 Exit For
  946.                                 
  947.                             End If
  948.                            
  949.                         Next
  950.                         
  951.                         If StnTmr.VideoOpt = 0 Then
  952.                         
  953.                             NewInput SrcGrp, 0, SelItem
  954.                                                    
  955.                         Else
  956.                             
  957.                             NewInput SrcGrp, 1, SelItem
  958.                                                                            
  959.                         End If
  960.                         
  961.     
  962.                     Else
  963.                         
  964.                         
  965.                         
  966.                         For Each SrcGrpN In SrcGrpCol
  967.                         
  968.                             If SrcGrpN.Name = "Current" Then
  969.                             
  970.                                 PlayCnt = PlayCnt + 1
  971.                                 
  972.                                 StnTmr.PlaylistPos = PlayCnt
  973.                                 
  974.                                 lvwStation.ListItems(I).ListSubItems.Item("Playlist").Text = PlayCnt & " of " & MaxCnt & " items"
  975.                                 
  976.                                 SrcGrpCol.Active = SrcGrpN
  977.                                 
  978.                                 Enc.Start
  979.                                                             
  980.                                 Exit For
  981.                             
  982.                             End If
  983.                         
  984.                         Next
  985.                         
  986.                         If StnTmr.VideoOpt = 0 Then
  987.                         
  988.                             NewInput SrcGrp, 0, SelItem
  989.                                                     
  990.                         Else
  991.                             
  992.                             NewInput SrcGrp, 1, SelItem
  993.                                                                             
  994.                         End If
  995.                         
  996.                     End If
  997.                 End If
  998.             End If 'this is new
  999.         End If
  1000.     Next
  1001.     
  1002.     Exit Sub
  1003.     
  1004. error_handler:
  1005. MsgBox "Error Processing Input", vbCritical
  1006.         
  1007. End Sub
  1008.  
  1009.  
  1010.  
  1011. Public Sub NewInput(SrcGrp As IWMEncSourceGroup, Video As Integer, SelItem As String)
  1012.     On Error GoTo error_handler
  1013.     
  1014.     Dim ProcStn As StnMgrEnc
  1015.     
  1016.     Dim pos As Integer
  1017.     
  1018.     Dim UpLimit As Integer
  1019.     
  1020.     Dim FileInAud As String
  1021.     
  1022.     Dim FileInVid As String
  1023.     
  1024.     Dim Dur As String
  1025.     
  1026.     Dim AudioSrc As IWMEncSource
  1027.     Dim VideoSrc As IWMEncSource
  1028.     
  1029.     Set ProcStn = StnCol.Item(SelItem)
  1030.     
  1031.     pos = ProcStn.PlaylistPos
  1032.     
  1033.     UpLimit = ProcStn.MaxBound
  1034.     
  1035.     If pos >= UpLimit Then
  1036.          
  1037.          ProcStn.LstStop = 1
  1038.          
  1039.          Exit Sub
  1040.     
  1041.     End If
  1042.             
  1043.     pos = pos + 1
  1044.     
  1045.     ProcStn.AllElem FileInVid, FileInAud, Dur, pos
  1046.     
  1047.     If Video = 0 Then
  1048.         Set AudioSrc = SrcGrp.Source(WMENC_AUDIO, 0)
  1049.         If Dur = "-" Then
  1050.             
  1051.             FileInAud = "FILE://" & FileInAud
  1052.             
  1053.             AudioSrc.SetInput FileInAud
  1054.         
  1055.         Else
  1056.         
  1057.             AudioSrc.SetInput FileInAud
  1058.             
  1059.         End If
  1060.     Else
  1061.         
  1062.         Set AudioSrc = SrcGrp.Source(WMENC_AUDIO, 0)
  1063.                         
  1064.         Set VideoSrc = SrcGrp.Source(WMENC_VIDEO, 0)
  1065.     
  1066.         If Dur = "-" Then
  1067.             
  1068.             FileInAud = "FILE://" & FileInAud
  1069.             
  1070.             FileInVid = "FILE://" & FileInVid
  1071.             
  1072.             AudioSrc.SetInput FileInAud
  1073.             
  1074.             VideoSrc.SetInput FileInVid
  1075.         Else
  1076.             FileInAud = "DEVICE://" & FileInAud
  1077.             
  1078.             If FileInVid = "Screen Capture" Then
  1079.                 FileInVid = "ScreenCap://"
  1080.             Else
  1081.                 FileInVid = "DEVICE://" & FileInVid
  1082.             End If
  1083.             
  1084.             AudioSrc.SetInput FileInAud
  1085.             
  1086.             VideoSrc.SetInput FileInVid
  1087.         End If
  1088.     End If
  1089.     
  1090.     Exit Sub
  1091.     
  1092. error_handler:
  1093.  
  1094. MsgBox "Eroor In The Playlist Elements", vbCritical
  1095.     
  1096. End Sub
  1097.