Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Button freezes Pythonista
-
@tony Yes, please. As of right now when I press take photo or video it just crashes.
-
@tony, instead of pasting your code here, it would be best if you edited the program at https://github.com/tjferry14/Fun-Pythonista-Tools/blob/master/speech.py and the submitted a "pull request". That way we can all be looking at the same version.
-
@ccc I'll maybe let techteej to do that when he's happy with his version.
@techteej Import sound (just temporarily while you're testing, the beep will confirm the script is waiting for the video file) and then give ids to the form and submit button of form and submit. Then use this in your microphone button...
sender.superview['webview1'].evaluate_javascript('document.getElementById("file").click()') def loop(): if sender.superview['webview1'].evaluate_javascript('document.forms["form"]["file"].value') == '': sound.play_effect('Beep') ui.delay(loop,2) else: sender.superview['webview1'].evaluate_javascript('document.getElementById("submit").click()') loop()
-
@tony This still crashes Pythonista.
-
@techteej It works here on iPad mini (original). If it doesn't work for you (from a clean start of Pythonista) then it may be to do with the threading issue. It's only a guess why the ui.delay of an empty function for zero time helps, all we can say for sure is 'it does because it does' on one device anyway.
When Pythonista gets into the threading issue... one run of a script is not necessarily the same as a second... so it's worth to try from a clean start of Pythonista, (if you haven't already). Otherwise I don't know what to say except it must be frustrating (been there!)
-
I am struggling to understand this code.
get_unused_filename()
anddo_POST()
never get called.do_GET()
only gets called once with self.path set to '/'.What is supposed to happen after the user clicks "Use Video"?
-
@ccc That part is basically @omz's file transfer script. The flow goes...
First GET to the server is for the HTML.
The POST will happen when the video file is being submitted... maybe you haven't got to that point. In turn it will call 'get unused file name' to get a free one if the name of the uploaded file is in use.
iOS will pop up a choice to take a new photo/video or choose an exiting one... any of the choices are ok, and whatever file results will be uploaded, when the user (or the JavaScript) clicks the submit button.
If you're using the JavaScript the user will never see the web page or the buttons, just the iOS pop up, which is nice and clean.
-
So when you click "Use Video" does
do_Post()
get called? -
@ccc Yes... when the user (or the JavaScript) clicks the submit button. If you're using the JavaScript the user will never see the web page or buttons, just the iOS popup, which is nice and clean.
-
When I check the code out of the repo and run it and tap the record button and select "video" and record a video and tap "Use Video" nothing happens. There is no video file stored in the local directory. The beep in the background continues every 2 seconds until Pythonista times out.
Are you using the current code in the repo? What is the name and full path of the video file that gets saved?
-
@ccc The repo is missing the step of adding ids to the form and submit button of form and submit respectively. The file is saved to the same directory as the script. For a video it's capturedvideo.MOV.
-
I just submitted a pull request with the two ids added.