Using NativeScript's strengths by tapping directly into the native API of the underlying iOS AVAudioPlayer instance from the nativescript-audio plugin

Let's insert some safeguards into our play/pause logic to help ensure our tracks stay in sync to the best of our programming abilities. The nativescript-audio plugin offers an iOS-only method called playAtTime. It works in tandem with the special deviceCurrentTime property, as described in Apple's documentation for this very purpose at https://developer.apple.com/reference/avfoundation/avaudioplayer/1387462-devicecurrenttime? language=objc.

Since deviceCurrentTime is not exposed by the nativescript-audio plugin, we can access the native property directly via the ios getter. Let's adjust the  ...

Get NativeScript for Angular Mobile Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.