cannot use program until tShellCommand is stopped.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
drolaz
Posts: 17
Joined: Fri Jan 18, 2013 7:10 pm

cannot use program until tShellCommand is stopped.

Post by drolaz » Fri Jan 18, 2013 7:28 pm

Hello everyone!
This is my first post and I am very very new to programming but have made it pretty far via tutorials and such.
But now im stuck and need any assistance that could be given.

This programs purpose is to connecting to a IP camera and this program has to use ffmpeg/ffplay. (another player is not an option)

What I have so far works exactly as I need it to however when the video starts I cannot touch any other button on the app until the video is stopped.
If i do hit buttons while video is playing it seems to store what I hit in memory and will exectute once the video is stopped.
Note video is stopped by closing the video window.

This program is built on one stack. Is this my problem? Is it that I need to use some time of while-then statement.

Any help would be appricated.

Below is a sample of what the script is so far. other functions are the same but are used for recording or taking snapshots.

on mouseUp
answer "Video feed will begin shortly..Press OK to continue.."
put field "ipaddress" into IpAddress
put "C:/ff/bin/ffplay -i rtsp://" into Path
put ":8554/main" & space & "-ss" & space & "3" & space & "-x" & space & "640" & space & "-y" & space & "380" into MainPlay
put Path & IpAddress & MainPlay into tShellCommand
set the hideconsolewindows to true
put shell(tShellCommand)
end mouseUp

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: cannot use program until tShellCommand is stopped.

Post by sturgis » Fri Jan 18, 2013 7:40 pm

Shell is a blocking command as you have seen. There are a couple options. Since you're on windows you could use open process and interact with ffmpeg/ffplay, or if you don't need to get data back and just start the apps in question you could use launch.

something like:

Code: Select all

launch "path/to/document" with "/path/to/application"
In this case of course the document path would be your url.

drolaz
Posts: 17
Joined: Fri Jan 18, 2013 7:10 pm

Re: cannot use program until tShellCommand is stopped.

Post by drolaz » Fri Jan 18, 2013 8:33 pm

Sturgis!
Thanks for the quick reply. Changing to Launch did the trick now I can click other buttons.
However another issue has popped up and if I can massage your brain for another tidbit of helpful data....

launch "rtsp://10.0.27.220:8554/main" with "c:/ff/bin/ffplay.exe" works but need to use data from field...

want to use:

launch "FfplayString" with "c:/ff/bin/ffplay.exe"

However it does not work?
Are fields not excepted?

put field "ipaddress" into IpAddress
put "rtsp://" into Path
put ":8554/main" into MainPlay
put Path & IpAddress & MainPlay into FfplayString

Again thank you sooooooo much for everyones help!
Al

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: cannot use program until tShellCommand is stopped.

Post by sturgis » Fri Jan 18, 2013 8:50 pm

Since your playstring is a variable, don't use quotes around it. If you do the variable wont' be evaluated, the engine will just think you're passing a string "FfplayString"

Also, you might look at the merge command to make some of this easier.

It looks like you will want to end up with an address like

rstp://ipaddress:8554/main

Since the only thing that is changing is the ipaddress you can store your full string into a variable so that it looks like this..

rstp://[[field "ipaddress"]]:8554/main

Then when you do your launch you can simply do

launch merge(myVariable) with "c:/ff/bin/ffplay.exe" and the current ip address will be merged in to take the place of field "ipaddress" items between [[ ]] are evaluated by the engine producing the final desired string.

drolaz
Posts: 17
Joined: Fri Jan 18, 2013 7:10 pm

Re: cannot use program until tShellCommand is stopped.

Post by drolaz » Fri Jan 18, 2013 10:07 pm

Sturgis that worked!
Thanks so much for your help.
Al

Post Reply