Search in sources :

Example 6 with WritableMap

use of com.facebook.react.bridge.WritableMap in project react-native-video by react-native-community.

the class VideoEventEmitter method load.

void load(double duration, double currentPosition, int videoWidth, int videoHeight) {
    WritableMap event = Arguments.createMap();
    event.putDouble(EVENT_PROP_DURATION, duration / 1000D);
    event.putDouble(EVENT_PROP_CURRENT_TIME, currentPosition / 1000D);
    WritableMap naturalSize = Arguments.createMap();
    naturalSize.putInt(EVENT_PROP_WIDTH, videoWidth);
    naturalSize.putInt(EVENT_PROP_HEIGHT, videoHeight);
    if (videoWidth > videoHeight) {
        naturalSize.putString(EVENT_PROP_ORIENTATION, "landscape");
    } else {
        naturalSize.putString(EVENT_PROP_ORIENTATION, "portrait");
    }
    event.putMap(EVENT_PROP_NATURAL_SIZE, naturalSize);
    // TODO: Actually check if you can.
    event.putBoolean(EVENT_PROP_FAST_FORWARD, true);
    event.putBoolean(EVENT_PROP_SLOW_FORWARD, true);
    event.putBoolean(EVENT_PROP_SLOW_REVERSE, true);
    event.putBoolean(EVENT_PROP_REVERSE, true);
    event.putBoolean(EVENT_PROP_FAST_FORWARD, true);
    event.putBoolean(EVENT_PROP_STEP_BACKWARD, true);
    event.putBoolean(EVENT_PROP_STEP_FORWARD, true);
    receiveEvent(EVENT_LOAD, event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap)

Example 7 with WritableMap

use of com.facebook.react.bridge.WritableMap in project react-native-video by react-native-community.

the class VideoEventEmitter method seek.

void seek(long currentPosition, long seekTime) {
    WritableMap event = Arguments.createMap();
    event.putDouble(EVENT_PROP_CURRENT_TIME, currentPosition / 1000D);
    event.putDouble(EVENT_PROP_SEEK_TIME, seekTime / 1000D);
    receiveEvent(EVENT_SEEK, event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap)

Example 8 with WritableMap

use of com.facebook.react.bridge.WritableMap in project react-native-video by react-native-community.

the class VideoEventEmitter method audioFocusChanged.

void audioFocusChanged(boolean hasFocus) {
    WritableMap map = Arguments.createMap();
    map.putBoolean(EVENT_PROP_HAS_AUDIO_FOCUS, hasFocus);
    receiveEvent(EVENT_AUDIO_FOCUS_CHANGE, map);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap)

Example 9 with WritableMap

use of com.facebook.react.bridge.WritableMap in project react-native-video by react-native-community.

the class VideoEventEmitter method timedMetadata.

void timedMetadata(Metadata metadata) {
    WritableArray metadataArray = Arguments.createArray();
    for (int i = 0; i < metadata.length(); i++) {
        Id3Frame frame = (Id3Frame) metadata.get(i);
        String value = "";
        if (frame instanceof TxxxFrame) {
            TxxxFrame txxxFrame = (TxxxFrame) frame;
            value = txxxFrame.value;
        }
        String identifier = frame.id;
        WritableMap map = Arguments.createMap();
        map.putString("identifier", identifier);
        map.putString("value", value);
        metadataArray.pushMap(map);
    }
    WritableMap event = Arguments.createMap();
    event.putArray(EVENT_PROP_TIMED_METADATA, metadataArray);
    receiveEvent(EVENT_TIMED_METADATA, event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) TxxxFrame(com.google.android.exoplayer2.metadata.id3.TxxxFrame) Id3Frame(com.google.android.exoplayer2.metadata.id3.Id3Frame)

Example 10 with WritableMap

use of com.facebook.react.bridge.WritableMap in project react-native-video by react-native-community.

the class ReactVideoView method onPrepared.

@Override
public void onPrepared(MediaPlayer mp) {
    mMediaPlayerValid = true;
    mVideoDuration = mp.getDuration();
    WritableMap naturalSize = Arguments.createMap();
    naturalSize.putInt(EVENT_PROP_WIDTH, mp.getVideoWidth());
    naturalSize.putInt(EVENT_PROP_HEIGHT, mp.getVideoHeight());
    if (mp.getVideoWidth() > mp.getVideoHeight())
        naturalSize.putString(EVENT_PROP_ORIENTATION, "landscape");
    else
        naturalSize.putString(EVENT_PROP_ORIENTATION, "portrait");
    WritableMap event = Arguments.createMap();
    event.putDouble(EVENT_PROP_DURATION, mVideoDuration / 1000.0);
    event.putDouble(EVENT_PROP_CURRENT_TIME, mp.getCurrentPosition() / 1000.0);
    event.putMap(EVENT_PROP_NATURALSIZE, naturalSize);
    // TODO: Actually check if you can.
    event.putBoolean(EVENT_PROP_FAST_FORWARD, true);
    event.putBoolean(EVENT_PROP_SLOW_FORWARD, true);
    event.putBoolean(EVENT_PROP_SLOW_REVERSE, true);
    event.putBoolean(EVENT_PROP_REVERSE, true);
    event.putBoolean(EVENT_PROP_FAST_FORWARD, true);
    event.putBoolean(EVENT_PROP_STEP_BACKWARD, true);
    event.putBoolean(EVENT_PROP_STEP_FORWARD, true);
    mEventEmitter.receiveEvent(getId(), Events.EVENT_LOAD.toString(), event);
    applyModifiers();
    if (mUseNativeControls) {
        initializeMediaControllerIfNeeded();
        mediaController.setMediaPlayer(this);
        mediaController.setAnchorView(this);
        videoControlHandler.post(new Runnable() {

            @Override
            public void run() {
                mediaController.setEnabled(true);
                mediaController.show();
            }
        });
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap)

Aggregations

WritableMap (com.facebook.react.bridge.WritableMap)46 ReactContext (com.facebook.react.bridge.ReactContext)5 ThemedReactContext (com.facebook.react.uimanager.ThemedReactContext)4 RCTEventEmitter (com.facebook.react.uimanager.events.RCTEventEmitter)3 Intent (android.content.Intent)2 MediaMetadataRetriever (android.media.MediaMetadataRetriever)2 View (android.view.View)2 Callback (com.facebook.react.bridge.Callback)2 WritableNativeMap (com.facebook.react.bridge.WritableNativeMap)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Activity (android.app.Activity)1 BroadcastReceiver (android.content.BroadcastReceiver)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 IntentFilter (android.content.IntentFilter)1 AssetFileDescriptor (android.content.res.AssetFileDescriptor)1 Bitmap (android.graphics.Bitmap)1 Camera (android.hardware.Camera)1 Uri (android.net.Uri)1