feat(android): add playback functions to ref
This commit is contained in:
		@@ -116,7 +116,7 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
import java.lang.Integer;
 | 
			
		||||
 | 
			
		||||
@SuppressLint("ViewConstructor")
 | 
			
		||||
class ReactExoplayerView extends FrameLayout implements
 | 
			
		||||
public class ReactExoplayerView extends FrameLayout implements
 | 
			
		||||
        LifecycleEventListener,
 | 
			
		||||
        Player.Listener,
 | 
			
		||||
        BandwidthMeter.EventListener,
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ import com.facebook.react.bridge.NativeModule;
 | 
			
		||||
import com.facebook.react.bridge.ReactApplicationContext;
 | 
			
		||||
import com.facebook.react.uimanager.ViewManager;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -25,9 +26,12 @@ public class ReactVideoPackage implements ReactPackage {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
 | 
			
		||||
        return Collections.singletonList(
 | 
			
		||||
                new VideoDecoderPropertiesModule(reactContext)
 | 
			
		||||
        );
 | 
			
		||||
        List<NativeModule> modules = new ArrayList<NativeModule>();
 | 
			
		||||
 | 
			
		||||
        modules.add(new VideoDecoderPropertiesModule(reactContext));
 | 
			
		||||
        modules.add(new VideoManagerModule(reactContext));
 | 
			
		||||
        
 | 
			
		||||
        return modules;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Deprecated RN 0.47
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,39 @@
 | 
			
		||||
package com.brentvatne.react;
 | 
			
		||||
 | 
			
		||||
import android.view.View;
 | 
			
		||||
 | 
			
		||||
import androidx.annotation.NonNull;
 | 
			
		||||
 | 
			
		||||
import com.brentvatne.exoplayer.ReactExoplayerView;
 | 
			
		||||
import com.facebook.react.bridge.ReactApplicationContext;
 | 
			
		||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
 | 
			
		||||
import com.facebook.react.bridge.ReactMethod;
 | 
			
		||||
import com.facebook.react.uimanager.UIManagerModule;
 | 
			
		||||
 | 
			
		||||
public class VideoManagerModule extends ReactContextBaseJavaModule {
 | 
			
		||||
    ReactApplicationContext reactContext;
 | 
			
		||||
 | 
			
		||||
    @NonNull
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "VideoManager";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ReactMethod
 | 
			
		||||
    public void setPlayerStatus(Boolean shouldPlay, int reactTag) {
 | 
			
		||||
        UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class);
 | 
			
		||||
        uiManager.prependUIBlock(manager -> {
 | 
			
		||||
            View view = manager.resolveView(reactTag);
 | 
			
		||||
 | 
			
		||||
            if (view instanceof ReactExoplayerView) {
 | 
			
		||||
                ReactExoplayerView videoView = (ReactExoplayerView) view;
 | 
			
		||||
                videoView.setPausedModifier(!shouldPlay);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public VideoManagerModule(ReactApplicationContext reactContext) {
 | 
			
		||||
        super(reactContext);
 | 
			
		||||
        this.reactContext = reactContext;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user