Possible to learn a device's orientation in document.ready() event? - jquery-mobile

I'm retrieving a mobile device's orientation in the window.load event in jQuery. The problem, of course, is this event isn't fired until all images etc are loaded into the browser. Therefore my app's reaction time is slowed.
I'm retrieving the orientation in the load event by calling $.event.special.orientationchange.orientation(), which works great for both the load and orientationchange events. However, I don't see any event argument passed into document.ready(), so I can't seem to learn the device's orientation at that time.
Is it possible to do this, to figure out the device's orientation in document.ready()?

Better use jQueryMobile event pageinit instead of document.ready(). See the reference in the documentation: http://jquerymobile.com/demos/1.2.0/docs/api/events.html

Related

Screen frame render finished / presented callback

I'd like to know the exact moment when screen frame finishes rendering and gets displayed, so I can capture specific window images with quartz api. There is CVDisplayLink / CADisplayLink that allows application to synchronise its drawing to the refresh rate of the display.
As I understand, those methods are very similar to what I need, but invoked when screen frame needs to be rendered, not when it finished and presented, meaning that if I capture the current screen image at that time I'd only see the previous render. Is this correct thinking?
If yes, is there a way to do get notified when the frame has actually finished rendered and was presented? Maybe there's private api for that? Ideally I need an answer for macOS, but if you happen to know how to do this in iOS, please let know.
P.S. I'm aware of CGDisplayStream, it's a great solution for capturing the whole screen, not specific windows – it uses run loops and dispatch queues, meaning that callbacks are not invoked in realtime like with display links.

PJSIP 2.4 video orientation change propagation

In my application I am running into issues handling a scenario where a capture device on one side of the conversation changes his orientation, which needs to reflect on the rendering device on the other side.
I am using iOS and have figured out how to use pjsua_vid_win_rotate() to deal with changes of orientation assuming the capture side of the conversation is using a static orientation. The issue seems to be that the render side of the conversation does not get notified that the orientation of the video being sent to him has changed. What is the proper way to handle this with pjsip?
So basically the problem is as follows:
User A is in portrait.
User B is also in portrait and sets window rotation to 270. This leads to a proper video render.
User A changes orientation to landscape mid call.
User B needs to change his window rotation to 0 to accommodate the change but is not aware a change has been made.
There is an RTP extension that may be used to carry mobile orientation data. It isn't supported in PJSIP yet. summary of existing standards for CVO
Or you may wish to use application specific RTCP APP type packets to transmit in a custom format (freesoft.org/CIE/RFC/1889/33.htm)
Either one of these options will require changes to the way PJSIP listens to and creates RTP. This can be accomplished by creating a Media Transport Adapter: PJSIP Media Transport Adapter

Delphi - Simulate Click Animation

This is my first post here on stackoverflow so forgive me for anything I'm doing wrong.
I'm making a kind of guide to the users without any computer knowledge of my application where I show him how to use it by signalizing what he should do, more specifically where to click. I want to that by moving a "fake" cursor to the button and simulate a click, and here is where I got my problem, I have to simulate just the animation of the click, and not the event itself but I couldn't find a way to do that, can anyone help me?
What you're describing is exactly what WH_JOURNALPLAYBACK is for. It populates the message queue with the mouse and keyboard messages you want to occur, and the OS interprets them. In your case, activate the playback hook and perform the mouse events necessary for performing a click.
In preparation, you'll probably want to use WH_JOURNALRECORD to discover what messages you need. Once you have them, you can probably winnow them down to a reasonably sized list prior to shipping your product to customers. (In particualr, you'll probably record many more mouse-move messages than you really need.)
In your button's click handler, check whether playback is active. Only perform the rest of the event handler when playback isn't active. That way, your program will behave just as though the button were clicked (including any animation), but it won't execute the real event code.

Change zoomScale and contentOffset of UIScrollView in UIApplicationStateBackground state

I know it's not recommended to change any view appearance when the application is moved to background state, but for my specific task I cannot postpone this activity and I really like to complete it in a couple of seconds after the user hits the home button.
That's what I do:
I load a webpage in a UIWebView and after loading completion I change the contentOffset and zoomScale in order to make a specific screenshot of that webpage. When the app is in active application state everything works fine.
Now I wanted to add some more multitasking capabilities. I encapsulated the above described webpage loading and rendering activity in a protected background task (iOS Task Completion), in order to complete it even when the user hits the home button.
I have noticed that the page loading and the rendering of the webpage screenshot (with the renderInContext: method) works just fine in background, BUT it seems that the webview (i.e. the encapsulated UIScrollView instance) does not react on setContentOffset: and setZoomScale: messages as soon as the app is in background..
So I'm asking you if you know any alternatives to change the content offset / zoomscale? (modifications directly on CALayer?) Or any method to "force" the scrollview to perform the content changes even in background.
PS: On the iOS simulator everything works fine even in application background state, but on real devices it does not.
EDIT: I have created a simple demo project that demonstrates the issue. You can download it here (please read the instructions in the zip file): http://dl.dropbox.com/u/3556271/BackgroundBugDemo.zip
I appreciate every hint or tip. Thanks!

UILocalNotifcation custom fire event, or struggle on with NSTimer

I have a state-transition problem with NSTimer, of which I find difficult to keep track of during applicationWillResignActive / applicationDidEnterBackground, according to the context of my app.
I was wondering if it might not be a better idea to utilise UILocalNotification, especially given it's background/inactive firing. However, I wanted to know whether we have the ability to provide a custom method to UILocalNotification, of which does not present a dialog box (would damage the whole point of my app). In effect, i'd like to only make use of the timer-fire capabilities of UILocalNotification, and handle the fire event with my own method which does something very "undialog-friendly"
Have checked the ADC docs and it alludes to the dialog being presented every time.
Any advice you can give on this would be appreciated.
thanks
sc.
The dialog box is presented when your app is in the background. But it is not presented when your app is running - instead your app is free to deal with the notification however it sees fit. So it would be perfectly possible to hook it up to a custom method of your own making.
The main reason for this behaviour is a user may not want to go into your app if it's in the background. Of course, with iOS 5 the notification may not be a dialog box - it could be one of the new notification styles.

Resources