#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=mpc-hc64_128.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include #include #include #include #include "GUIListViewEx.au3" #include #include #include #include ; Build main GUI $Form1 = GUICreate("MPC Show Editor", 922, 717, -1, -1) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("New", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Load", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("Save", $MenuItem1) $MenuItem5 = GUICtrlCreateMenuItem("Quit", $MenuItem1) $MenuItem6 = GUICtrlCreateMenu("&Help") $MenuItem7 = GUICtrlCreateMenuItem("About", $MenuItem6) $MenuItem8 = GUICtrlCreateMenuItem("Help", $MenuItem6) GUISetFont(12, 400, 0, "MS Sans Serif") $ListView1 = GUICtrlCreateListView("Start|Duration|Title|Location", 136, 24, 761, 625, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOSORTHEADER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 550) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 900) _GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 1, 2) $Button1 = GUICtrlCreateButton("Add", 24, 136, 89, 41) GUICtrlSetTip(-1, "Add file to play list") $Button2 = GUICtrlCreateButton("Delete", 24, 208, 89, 41) GUICtrlSetTip(-1, "Remove file from play list") $Button3 = GUICtrlCreateButton("Up", 24, 280, 89, 41) GUICtrlSetTip(-1, "Move selected file one space up on play list") $Button4 = GUICtrlCreateButton("Down", 24, 352, 89, 41) GUICtrlSetTip(-1, "Move selected file one space down on play list") $Button5 = GUICtrlCreateButton("Info", 24, 424, 89, 41) GUICtrlSetTip(-1, "See information on selected media file") $Button6 = GUICtrlCreateButton("Playlist", 24, 496, 89, 41) GUICtrlSetTip(-1, "Generate MPC play list") $Group1 = GUICtrlCreateGroup("Start Time", 8, 32, 121, 73) $Button8 = GUICtrlCreateButton("12:00:00 AM", 16, 56, 105, 33) GUICtrlSetTip(-1, "Click here to enter intial start time for the show") GUICtrlCreateGroup("", -99, -99, 1, 1) $Button7 = GUICtrlCreateButton("Bundle", 24, 568, 89, 41) GUICtrlSetTip(-1, "Download and consolidate files in play list to local folder") $Label1 = GUICtrlCreateLabel("", 136, 664, 650, 24) GUISetState(@SW_SHOW) ; Initiate LVEx - no count - green insert parameter - no drag image - not sortable or editable $LV_Index = _GUIListViewEx_Init($ListView1, "", 1, 0x00FF00) ; Register for dragging and editing _GUIListViewEx_MsgRegister() ; Set the right ListView as active _GUIListViewEx_SetActive(1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(36,"New Playlist","Are you sure you wish to start a new playlist?") If $iMsgBoxAnswer = 6 Then _GUICtrlListView_DeleteAllItems($ListView1) GUICtrlSetData($Button8, "12:00:00 AM") EndIf Case $MenuItem5 Exit Case $Button1 $File = FileOpenDialog ("Choose files you wish to add", "", "All (*.*)", 7, "", $Form1) $AddFile = _AddFile($File) If $AddFile > 0 Then _GUIListViewEx_Insert($AddFile, False, False) _UpdateTimes() Case $Button2 _GUIListViewEx_Delete() _UpdateTimes() Case $Button3 _GUIListViewEx_Up() _UpdateTimes() Case $Button4 _GUIListViewEx_Down() _UpdateTimes() Case $Button5 $Index = _GUICtrlListView_GetSelectedIndices($ListView1) If Not $Index = "" Then $InfoFileName = _GetFileInfoPath($Index) Run(@ScriptDir & "\MIViewer.exe " & Chr(34) & $InfoFileName & Chr(34)) EndIf Case $Button6 Case $Button7 Case $Button8 _SetStartTime() _UpdateTimes() EndSwitch WEnd Func _AddFile($File) If $File = "" Then Return 0 $FileName = _GetFileName($File) GUICtrlSetData($Label1, "Adding... " & $FileName) $Duration = _GetDuration($File) $Duration = _Convert2Min($Duration) $RetStr = ("12:00:00" & "|" & $Duration & "|" & $FileName & "|" & $File) GUICtrlSetData($Label1, "") Return($RetStr) EndFunc Func _CalcTime($StartTime, $AddTime) $StartTime = (_NowCalcDate() & " " & $StartTime) $EndTime = _DateAdd ('n', $AddTime, $StartTime) $EndTime = StringTrimLeft($EndTime, 11) $Time = _StringExplode ($EndTime, ":") $Hour = $Time[0] $Min = $Time[1] $Sec = $Time[2] If Number($Hour) = 0 Then $Hour = 12 If Number($Hour) > 12 Then $Hour = ($Hour - 12) $ReturnTime = ($Hour & ":" & $Min & ":" & $Sec) If StringLeft($ReturnTime,1) = "0" Then $ReturnTime = StringTrimLeft($ReturnTime,1) EndIf Return $ReturnTime EndFunc Func _Convert2Min($Time) $MinTime = _StringExplode ($Time, ":") $Hour = Number($MinTime[0]) $Min = Number($MinTime[1]) $MinReturn = ($Hour * 60) $MinReturn = $MinReturn + $Min Return $MinReturn EndFunc Func _GetDuration($Movie) If Not FileExists (@ScriptDir & "\MediaInfo.dll") Then Return(-1) Dim $Result[1] $DLL=DllOpen("MediaInfo.dll") $Handle=DllCall($DLL, "ptr", "MediaInfo_New") $Open_Result=DllCall($DLL, "int", "MediaInfo_Open", "ptr", $Handle[0], "wstr", $Movie) DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Duration/String3%") $Inform=DllCall($DLL, "wstr", "MediaInfo_Inform", "ptr", $Handle[0], "int", 0) $Result[0] = $Inform[0] $Handle=DllCall($DLL, "none", "MediaInfoList_Delete", "ptr", $Handle[0]) DllClose($dll) Return (StringTrimRight($Result[0], 4)) EndFunc Func _GetFileInfoPath($Index) $ArrayList = _GUIListViewEx_ReturnArray($LV_Index, 0) $SelectedIndex = $ArrayList[$Index + 1] $ArraySplit = StringSplit($SelectedIndex, "|", 2) Return ($ArraySplit[3]) EndFunc Func _GetFileName($File) Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" Local $aPathSplit = _PathSplit($File, $sDrive, $sDir, $sFilename, $sExtension) Return ($aPathSplit[3]) EndFunc Func _SetStartTime() $CurrentStart = GUICtrlRead($Button8) $SSTForm1 = GUICreate("Set Start Time", 242, 76, -1, -1) $SSTDate1 = GUICtrlCreateDate($CurrentStart, 24, 24, 121, 28, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT)) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $SSTButton1 = GUICtrlCreateButton("Set", 160, 22, 65, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($SSTForm1) Return Case $SSTButton1 $NewStart = GUICtrlRead($SSTDate1) GUICtrlSetData($Button8, $NewStart) GUIDelete($SSTForm1) Return EndSwitch WEnd EndFunc Func _UpdateTimes() $LVArray = _GUIListViewEx_ReturnArray($LV_Index, 0) $StartTime = GUICtrlRead($Button8) $StartTimeClipped = StringTrimRight($StartTime, 3) _GUICtrlListView_SetItemText($ListView1, 0, $StartTimeClipped, 0) If $LVArray[0] > 1 Then For $L = 1 To $LVArray[0] $First = _GUICtrlListView_GetItemText ($ListView1, $L-1) $Second = _GUICtrlListView_GetItemText ($ListView1, $L-1, 1) $StartTime = _CalcTime($First, $Second) _GUICtrlListView_SetItemText($ListView1, $L, $StartTime, 0) Next EndIf EndFunc