Jump to content

System default player from DMS recordings


majstang

Recommended Posts

I am wondering if there could be an option in DMS Recordings tab to play a recording with the windows system default player associated with .ts (in my case the very nice TSPlayer)?

Link to comment

Difficult.

 

Browsers can't handle it in a useful way. They will try to download the file before passing it to a player.

 

The DMS standard configuration can't handle it either because it is not able to launch GUI applications in the active user account. It would require special measures (extended privileges, see DMS options -> Tasks), which are not compatible with a configuration for accessing a protected NAS (requiring the DMS to log in with the username and password of an according user account).

 

So the only way I can see is passing the path\filename to the tray application in order to let it launch the app. But that's quite complicated ;)

 

Link to comment

So here is my take on it, provided a button for each entry in DMS Recordings tab does use something similar to an after recording task which sends a parameter/placeholder containing "{SOURCE_FILE}" to this sender script:

#NoTrayIcon
SetBatchLines -1 ;Have the script working at maximum speed

Loop %0%  ; For each parameter (or file dropped onto a script):
{
  Givenpath := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
  Loop %GivenPath%, 1
  {
   Params := A_LoopFileLongPath
   AddToBOF(A_ScriptDir . "\params.log", a_yyyy "-" a_mm "-" a_dd " " a_hour ":" a_min ":" a_sec " - " "params: " . Params . "`r`n")
   SystemDefaultPlayer(Params)
  }
}
ExitApp

SystemDefaultPlayer(PlayThatRecording) {
   If PlayThatRecording =
	  return
   Else
   {
	 pipe_name := "RecordingPlayer"
     FileOpen("\\.\pipe\" pipe_name, "w", "UTF-8-RAW").Write(PlayThatRecording)
   }
}

AddToBOF(FileName, String) { ; AddToBeginOfFile
   If (File := FileOpen(FileName, "rw", "UTF-8-RAW")) {
      Content := File.Read()
      File.Pos := 0
      File.Write(String . Content)
      File.Close()
      Return True
   }
   Return False
}

The sender script (still runs in the service environment) sends over the path/filename through a "Named pipe" to a receiver script which is already running if integrated into the DMS tray application. The pipe made sure we are nw in the user environment where GUIs can be opened. The receiver script starts the system default GUI player and plays the file. Works perfectly for me (as after recording tasks that is):)

 

Receiver script:

#NoEnv
#NoTrayIcon

pipe_name := "RecordingPlayer"

hpipe := CreateNamedPipe(pipe_name, 1|0x40000000)  ; PIPE_ACCESS_INBOUND=1 FILE_FLAG_OVERLAPPED=0x40000000
if (hpipe = -1) {
    MsgBox CreateNamedPipe failed.
    ExitApp
}
pipe := FileOpen(hpipe, "h", "UTF-8-RAW")

; Wait for a connection.
while ConnectNamedPipe(hpipe)
{
    ; Read the message incrementally (if it is long).
    message := ""
    while "" != (data := pipe.Read(4096))
		message .= data
       
    ; Process the message.
	FileName := message
	SetTimer, Runline, -2000 
		  		
    ; Disconnect so that we can accept another connection.
    DllCall("DisconnectNamedPipe", "ptr", hpipe)	
}

pipe := ""
DllCall("CloseHandle", "ptr", hpipe)

Runline:
Run, Open %FileName% ; or just Run, %FileName%
FileName =
return

;---FUNCTIONS-----------------------------------------------------------------------------------
CreateNamedPipe(Name, OpenMode=3, PipeMode=0, MaxInstances=255) {
    return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode
        ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,"ptr",0,"ptr")
}

ConnectNamedPipe(hNamedPipe) {
    hEvent := DllCall("CreateEvent", "ptr", 0, "int", true, "int", false, "ptr", 0, "ptr")
    VarSetCapacity(overlapped, 32, 0)
    NumPut(hEvent, overlapped, 2*A_PtrSize+8)
    r := DllCall("ConnectNamedPipe", "ptr", hNamedPipe, "ptr", &overlapped)
    if (!r && A_LastError = 997) {  ; ERROR_IO_PENDING
        loop {
            ; Wait for the event to be signaled or any window message received.
            r := DllCall("MsgWaitForMultipleObjectsEx", "uint", 1, "ptr*", hEvent
                , "uint", -1, "uint", 0x4FF, "uint", 0x6)
            Sleep, 1 ; Allow AutoHotkey to dispatch messages.
        }
        until r=0 or r=-1  ; WAIT_OBJECT_0 or WAIT_FAILED
    }
    DllCall("CloseHandle", "ptr", hEvent)
    return DllCall("GetOverlappedResult", "ptr", hNamedPipe, "ptr", &overlapped, "uint*", 0, "int", true)
}

 These are autohotkey scripts and can maybe be converted to Delphi?

Edited by majstang
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...