Detect If iOS11 Device Is in Low Power Mode to Prevent Bad Ux on Normally Correctly Autoplaying Video

Background video not auto playing on safari browser used svelte to build the website

The video is encoded by AV1 which is not supported by Safari entire apple ecosystem and Firefox on Android source

Get low power status in app

There are two ways for that.

  1. You can register for Power State Notifications.

    [NSNotificationCenter defaultCenter] addObserver:self selector: @selector(yourMethodName:) name:NSProcessInfoPowerStateDidChangeNotification object: nil];

  2. Or you can determine the current state.

    [[NSProcessInfo processInfo] isLowPowerModeEnabled]

The best thing what i think its really great for user experience point of view as per the Apple documentation is: Your app should take additional steps to help the system save energy when Low Power Mode is active. For example, your app could reduce the use of animations, lower frame rates, stop location updates, disable syncs and backups, and so on

I know there is already an answer for this (as per the comment dandan78) with links only no description, so posting bcoz it will be good if we have something here as well.

Detect if device is charging

Yes, UIDevice is capable of telling you this:

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];

if ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging) {
NSLog(@"Device is charging.");
}

See the UIDevice reference in the docs for more info, and for other values of batteryState.

Autoplay muted video iOS 11.2

Just turn off the "Low Power Mode" ;)



Related Topics



Leave a reply



Submit