use of com.facebook.react.bridge.WritableMap in project react-native-navigation by wix.
the class TitleBarSearchButton method onFocusChange.
@Override
public void onFocusChange(View v, boolean hasFocus) {
WritableMap arguments = Arguments.createMap();
arguments.putBoolean("hasFocus", hasFocus);
sendEvent("searchFocusChange", arguments);
}
use of com.facebook.react.bridge.WritableMap in project react-native-android-video-editor by RZulfikri.
the class VideoTrim method getVideoInfo.
// public void setMaxTrimDuration(int maxTrimDuration){
// this.maxTrimDuration = maxTrimDuration;
// }
/**
* Function to get Video Detail, used to get video Duration and Set Video Player Max Duration
*/
private void getVideoInfo(String source) {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(source);
duration = Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
if (duration / 60000 >= 10) {
maxDuration = 600000;
// videoPlayerControl.setEndPos(maxDuration);
WritableMap event = Arguments.createMap();
event.putInt(Events.END_POS, maxDuration);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_END_POS.toString(), event);
} else {
maxDuration = duration;
rangeSeekEndPos = maxDuration;
// videoPlayerControl.setEndPos(maxDuration);
WritableMap event = Arguments.createMap();
event.putInt(Events.END_POS, maxDuration);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_END_POS.toString(), event);
}
// Log.e("DEBUG", " "+duration+" "+maxDuration+" "+((minTrimDuration * 100f) / (float)maxDuration));
seekbar.setRangeMin((minTrimDuration * 100f) / (float) maxDuration);
mediaMetadataRetriever.release();
}
use of com.facebook.react.bridge.WritableMap in project react-native-android-video-editor by RZulfikri.
the class VideoTrim method setupListener.
/**
* Function to setup Gesture listener
*/
private void setupListener() {
/*
Listener to scrool video preview timeline when video timeline
more than layout width
*/
videoTimeline.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, final MotionEvent event) {
switch(event.getAction()) {
// Detect Touch Down
case MotionEvent.ACTION_DOWN:
move1 = (int) event.getX();
break;
// Detect when gesture move
case MotionEvent.ACTION_MOVE:
// Detect if video preview timeline posision equal than layout start
if (videoTimeline.getCanvasWidthStart() == 0) {
// Detect when scroll to left
if ((int) event.getX() <= move1) {
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (isScrollRight && !isScrollLeft) {
move4 = 0;
}
move2 = (int) event.getX();
if (Math.abs((move1 - move2) - move4) < (videoTimeline.getCanvasWidth() - usedWidth)) {
move3 = move1 - move2;
move5 = move5 + (move3 - move4);
videoTimeline.setXPos(-Math.abs(move5));
canvasSeekPos = (move5 * duration) / (videoTimeline.getCanvasWidth() + Math.abs(videoTimeline.getCanvasWidthStart()));
// videoPlayerControl.setStartPos(rangeSeekPos + canvasSeekPos);
// videoPlayerControl.setEndPos(rangeSeekEndPos+canvasSeekPos);
WritableMap event = Arguments.createMap();
event.putInt(Events.START_POS, rangeSeekPos + canvasSeekPos);
WritableMap event2 = Arguments.createMap();
event2.putInt(Events.END_POS, rangeSeekEndPos + canvasSeekPos);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_START_POS.toString(), event);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_END_POS.toString(), event2);
move4 = move3;
isScrollRight = false;
isScrollLeft = true;
}
}
});
thread.run();
}
} else // Detect if video preview timeline posision less than layout start
if (videoTimeline.getCanvasWidthStart() < 0) {
// Detect when scroll to left
if ((int) event.getX() <= move1) {
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (isScrollRight && !isScrollLeft) {
move4 = 0;
}
move2 = (int) event.getX();
if (Math.abs((move1 - move2) - move4) < (videoTimeline.getCanvasWidth() - usedWidth)) {
move3 = move1 - move2;
move5 = move5 + (move3 - move4);
videoTimeline.setXPos(-Math.abs(move5));
canvasSeekPos = (move5 * duration) / (videoTimeline.getCanvasWidth() + Math.abs(videoTimeline.getCanvasWidthStart()));
// videoPlayerControl.setStartPos(rangeSeekPos + canvasSeekPos);
// videoPlayerControl.setEndPos(rangeSeekEndPos+canvasSeekPos);
WritableMap event = Arguments.createMap();
event.putInt(Events.START_POS, rangeSeekPos + canvasSeekPos);
WritableMap event2 = Arguments.createMap();
event2.putInt(Events.END_POS, rangeSeekEndPos + canvasSeekPos);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_START_POS.toString(), event);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_END_POS.toString(), event2);
move4 = move3;
isScrollRight = false;
isScrollLeft = true;
}
}
});
thread.run();
} else // Detect when scroll to right
if ((int) event.getX() > move1) {
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (!isScrollRight && isScrollLeft) {
move4 = 0;
}
move2 = (int) event.getX();
if (Math.abs((move5 - ((move2 - move1) - move4))) < Math.abs(videoTimeline.getCanvasWidthStart())) {
move3 = move2 - move1;
move5 = move5 - (move3 - move4);
videoTimeline.setXPos(-Math.abs(move5));
canvasSeekPos = (move5 * duration) / (videoTimeline.getCanvasWidth() + Math.abs(videoTimeline.getCanvasWidthStart()));
// videoPlayerControl.setStartPos(rangeSeekPos + canvasSeekPos);
// videoPlayerControl.setEndPos(rangeSeekEndPos+canvasSeekPos);
WritableMap event = Arguments.createMap();
event.putInt(Events.START_POS, rangeSeekPos + canvasSeekPos);
WritableMap event2 = Arguments.createMap();
event2.putInt(Events.END_POS, rangeSeekEndPos + canvasSeekPos);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_START_POS.toString(), event);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_END_POS.toString(), event2);
move4 = move3;
isScrollRight = true;
isScrollLeft = false;
}
}
});
thread.start();
}
}
break;
case MotionEvent.ACTION_UP:
move4 = 0;
break;
default:
break;
}
return true;
}
});
/*
Listener for seekbar control (Seekbar button left and right)
index (0) = button seek left
index (1) = button seek right
value = value of seekButton (0 - 100)
*/
seekbar.addOnRangeSeekBarListener(new OnRangeSeekBarListener() {
@Override
public void onCreate(CustomRangeSeekBarView customRangeSeekBarView, int index, float value) {
}
@Override
public void onSeek(CustomRangeSeekBarView customRangeSeekBarView, int index, float value) {
if (index == 0) {
rangeSeekPos = (int) ((value / 100) * maxDuration);
canvasSeekPos = (move5 * duration) / (videoTimeline.getCanvasWidth() + Math.abs(videoTimeline.getCanvasWidthStart()));
// videoPlayerControl.setStartPos(rangeSeekPos + canvasSeekPos);
WritableMap event = Arguments.createMap();
event.putInt(Events.START_POS, rangeSeekPos + canvasSeekPos);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_START_POS.toString(), event);
} else {
rangeSeekEndPos = (int) (maxDuration * (value / 100));
// videoPlayerControl.setEndPos(rangeSeekEndPos+canvasSeekPos);
WritableMap event = Arguments.createMap();
event.putInt(Events.END_POS, rangeSeekEndPos + canvasSeekPos);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_END_POS.toString(), event);
}
}
@Override
public void onSeekStart(CustomRangeSeekBarView customRangeSeekBarView, int index, float value) {
}
@Override
public void onSeekStop(CustomRangeSeekBarView customRangeSeekBarView, int index, float value) {
}
});
}
use of com.facebook.react.bridge.WritableMap in project react-native-android-video-editor by RZulfikri.
the class VideoSurfaceView method paused.
public void paused(boolean isPaused) {
if (isPaused && mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
WritableMap event = Arguments.createMap();
event.putBoolean(Events.VIDEO_PLAYER_STATUS, false);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_VIDEO_PLAYER_STATUS.toString(), event);
}
if (!isPaused && !mMediaPlayer.isPlaying()) {
mMediaPlayer.start();
WritableMap event = Arguments.createMap();
event.putBoolean(Events.VIDEO_PLAYER_STATUS, true);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_VIDEO_PLAYER_STATUS.toString(), event);
}
}
use of com.facebook.react.bridge.WritableMap in project react-native-android-video-editor by RZulfikri.
the class VideoSurfaceView method onHostPause.
@Override
public void onHostPause() {
// Log.e("DEBUG", "PAUSE");
if (mMediaPlayer != null) {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
WritableMap event = Arguments.createMap();
event.putBoolean(Events.VIDEO_PLAYER_STATUS, false);
eventEmitter.receiveEvent(getId(), EventsEnum.EVENT_GET_VIDEO_PLAYER_STATUS.toString(), event);
}
// mMediaPlayer.release();
// mMediaPlayer = null;
onPaused = true;
}
}
Aggregations