feat: add plugins management (#3909)
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.videopluginsample">
|
||||
</manifest>
|
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</manifest>
|
@@ -0,0 +1,50 @@
|
||||
package com.videopluginsample
|
||||
|
||||
import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.exoplayer.util.EventLogger
|
||||
import com.brentvatne.common.toolbox.DebugLog
|
||||
import com.brentvatne.react.RNVPlugin
|
||||
import com.facebook.react.bridge.Promise
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
||||
import com.facebook.react.bridge.ReactMethod
|
||||
|
||||
class VideoPluginSampleModule(reactContext: ReactApplicationContext) :
|
||||
ReactContextBaseJavaModule(reactContext), RNVPlugin, Player.Listener {
|
||||
|
||||
private val debugEventLogger = EventLogger("RNVPluginSample")
|
||||
|
||||
override fun getName(): String {
|
||||
return NAME
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun setMetadata(promise: Promise) {
|
||||
promise.resolve(true)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val NAME = "VideoPluginSample"
|
||||
const val TAG = "VideoPluginSampleModule"
|
||||
}
|
||||
|
||||
override fun onPlayerError(error: PlaybackException) {
|
||||
DebugLog.e(TAG, "onPlayerError: " + error.errorCodeName)
|
||||
}
|
||||
|
||||
|
||||
override fun onInstanceCreated(id: String, player: Any) {
|
||||
if (player is ExoPlayer) {
|
||||
player.addAnalyticsListener(debugEventLogger)
|
||||
player.addListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInstanceRemoved(id: String, player: Any) {
|
||||
if (player is ExoPlayer) {
|
||||
player.removeAnalyticsListener(debugEventLogger)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.videopluginsample
|
||||
|
||||
import com.brentvatne.react.ReactNativeVideoManager
|
||||
import com.facebook.react.ReactPackage
|
||||
import com.facebook.react.bridge.NativeModule
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.uimanager.ViewManager
|
||||
|
||||
class VideoPluginSamplePackage : ReactPackage {
|
||||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
||||
val plugin = VideoPluginSampleModule(reactContext)
|
||||
ReactNativeVideoManager.getInstance().registerPlugin(plugin)
|
||||
return listOf(plugin)
|
||||
}
|
||||
|
||||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
||||
return emptyList()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user