npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pili-streaming-react-native

v2.0.0

Published

### 概述

Downloads

3

Readme

Pili 推流 SDK for react-native

概述

pili-streaming-react-native 是支持 React Native 项目添加直播推流功能的 SDK,底层基于 PLDroidMediaStreaming (Android) 和 PLMediaStreamingKit(iOS) 实现。

安装

1. 通过 npm 安装依赖包
npm i --save pili-streaming-react-native
2. 添加 android 支持
  1. 在 android 项目根目录下的 settings.gradle 中添加如下代码:

    include ':pili-streaming-react-native'
    project(':pili-streaming-react-native').projectDir = new File(settingsDir, '../node_modules/pili-streaming-react-native/android/pili-react-native')
  2. 在 android 项目的 app 目录下 build.gradle 文件中添加如下依赖:

    implementation "com.facebook.react:react-native:+" // From node_modules.
    implementation project(':pili-streaming-react-native')
  3. ReactApplication 的子类中定义 ReactNativeHost 对象,并重写其 getPackages 方法,将 PiliPackage 对象添加进去,示例代码如下:

    private final ReactNativeHost mReactNativeHost =
          new ReactNativeHost(this) {
            @Override
            public boolean getUseDeveloperSupport() {
              return BuildConfig.DEBUG;
            }
    
            @Override
            protected List<ReactPackage> getPackages() {
              @SuppressWarnings("UnnecessaryLocalVariable")
              List<ReactPackage> packages = new PackageList(this).getPackages();
              // Packages that cannot be autolinked yet can be added manually here, for example:
              // packages.add(new MyReactNativePackage());
              packages.add(new PiliPackage());
              return packages;
            }
    
            @Override
            protected String getJSMainModuleName() {
              return "index";
            }
          };
3. 添加 ios 支持

环境配置:Cocoapod 安装教程

  1. 打开 ios 文件夹,在 Podfile 文件中添加

    pod 'pili-react-native', :path => '../node_modules/pili-streaming-react-native/ios/pili-react-native'
  2. 终端运行

    cd ../ios
    pod install
  3. 打开 YourPorjectName.xcworkspace (这里请注意是打开 .xcworkspace!请确认)

  4. 运行 project (Cmd+R)

注意: 如果是 iOS 10 以上需要在 iOS 项目中的 info.plist 文件里额外添加如下权限:

<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>

<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>

<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>

使用

import { consts, Streaming } from './pili-react-native'

function Foo() {
  return (
    <Streaming
      rtmpURL="..."
      profile={{
        videoStreamingSetting: {
          fps: 30,
          bps: 800 * 1024,
          maxFrameInterval: 60
        },
        audioStreamingSetting: {
          rate: 44100,
          bitrate: 96 * 1024,
        },
        encodingSize: consts.videoEncoding480
      }}
    />
  )
}

更多高级功能配置,可以参考 Demo