CaptureMedia
-
Here is our work for capturing media (@techteej and @tony) from 2 other threads and @techteej's Speech project, tidied up, wrapped in a class, closing the server and presented in a popover sized to fit the iOS pop up.
The code uses a chunk from @omz's File Transfer script.
Only tested on an iPad mini (original) and the latest iOS 7 (see below), can't vouch for others.
# see version 2.1
Edit 2.1:
New version posted
Edit 2.0:
New public interface attributes of: version, source, message and file name
New compatibility testing in preparation for release of IOS 8
New close button in base class to prompt user action after cancel
New sub class example: MyCaptureMedia
Update: better fix for programmatic close of popover
Edit 1.0:
Notes for GitHub users regarding the items removed there:
-
The
_make_xxx
methods are according to @ccc's comments on best practices.... "Each ui element that gets added as a subview to your ui.View should have its ownmake_xxx()
method." http://omz-forums.appspot.com/pythonista/post/5826032204513280 -
The methods did load and layout are supplied as a provision for subclasses of CaptureMedia. Did load... gives the subclass the opportunity to add to or modify the ui of the class before it's presented, perhaps to make the WebView visible or leave it hidden but add extra buttons, etc. Layout gives the subclass the opportunity to change the size of the popover or adjust it for orientation changes etc.
-
The function of the
def log_message
is to suppress the default log messages to the console.
-
-
@ccc It's a bit of a fudge, but this addition to the base class seems to fix the quirk of present in a popover programmatic close for both the POST and the sub class button item action (and the fix line from POST can be removed)...
def close(self): self.will_close() super(CaptureMedia, self).close()
-
Updated source to version 2.0
-
last edited by
-
@techteej Thanks.
p.s. I'm working on adding in a settings button and my SettingsSheet class for a switch to turn warnings on/off.
-
@tony I have to test this on an iOS 7 iPad, which I don't see very often (it's a relatives) so good luck! Hopefully @ccc will help you. I can do what I can when I get the iOS 7 iPad.
-
@techteej Thanks :) Likewise when iOS 8 is out I'll have a way to try to get it working on that.
-
capture_media generates an error on line 115 on my ipad air ios7.... any fix?
-
Looks like you should replace self._f with
os.path.split(__file__)[1]
.
You might also want to try one of the older versions (github history) since it seems like people checked in work without testing.
-
@JonB thanks.
i've replaced the self._f at 2 locations, but there are still errors.
Which version in the history would your recommend?
-
Where is a working link?