react-native - 如何使用“react-native-android-pip”?
问题描述
我该如何使用它:https ://www.npmjs.com/package/react-native-android-pip 我想做一个 webview 应用程序可以使用 PIP(画中画)。但是我怎么能在我的代码中使用这个模块。
import * as React from 'react';
import { WebView } from 'react-native-webview';
import AndroidPip from 'react-native-android-pip';
export default class App extends React.Component {
render() {
return <WebView source={{ uri: '(My url)' }} style={{ marginTop: 50 }} />;
}
}
解决方案
正如这里所说(关于文档本身),您可以使用如下:
import AndroidPip from 'react-native-android-pip';
// Enter Pip mode
AndroidPip.enterPictureInPictureMode()
//Configure aspect ratio, works only on SDK version 26 and above
AndroidPip.configureAspectRatio(width, height)
// When enabled, PIP mode will be automatically entered when app is unfocused( User presses home
//, menu button etc)
AndroidPip.enableAutoPipSwitch()
AndroidPip.disableAutoPipSwitch()
您可以通过单击按钮、响应 API、启动屏幕等来调用这些函数...
[编辑] 另外,尝试使用这个模块的 github 版本,因为 npm 版本是 2 岁,而 github 版本是 29 天没有更新。安装如下:
npm install --save https://github.com/shaun-chiang/rn-android-pip
推荐阅读
- php - 创建 Session 对象时传递两个用户定义的键值对作为参数。我想在 checkout.session.completed 事件中收到它
- javascript - 根据复选框显示和隐藏行
- xml - 如何在 XSLT2 中使用字母和数字按自然顺序对组进行排序?
- node.js - 仅在第一次加载 Angular 网页时使用 Safari 接收 401 状态
- python - 创建 aws 子网标签
- r - 加速 R 的并行 SQL 查询?
- azure-maps - Azure Maps - 完成数据源加载时的事件
- python-3.x - 在 PySpark 中使用 for 循环动态加载数据帧
- node.js - 端口 4200 已在使用中。但它没有被采取
- mocking - 将 @PrepareForTest 与 Powermockito 一起使用时出错