Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of variables related to time to float #281

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RCTYouTubeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (dispatch_queue_t)methodQueue {
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
RCTYouTube *youtube = (RCTYouTube*)viewRegistry[reactTag];
if ([youtube isKindOfClass:[RCTYouTube class]]) {
NSNumber *index = [NSNumber numberWithInt:[youtube currentTime]];
NSNumber *index = [NSNumber numberWithFloat:[youtube currentTime]];
if (index) {
resolve(index);
} else {
Expand Down
2 changes: 1 addition & 1 deletion YouTube.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class YouTube extends React.Component {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this._nativeComponentRef),
UIManager.ReactYouTube.Commands.seekTo,
[parseInt(seconds, 10)],
[parseFloat(seconds, 10)],
);
}

Expand Down
2 changes: 1 addition & 1 deletion YouTube.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class YouTube extends React.Component {
};

seekTo(seconds) {
NativeModules.YouTubeManager.seekTo(ReactNative.findNodeHandle(this), parseInt(seconds, 10));
NativeModules.YouTubeManager.seekTo(ReactNative.findNodeHandle(this), parseFloat(seconds, 10));
}

nextVideo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void receiveCommand(YouTubeView view, int commandType, @Nullable Readable
Assertions.assertNotNull(args);
switch (commandType) {
case COMMAND_SEEK_TO: {
view.seekTo(args.getInt(0));
view.seekTo((float)(args.getDouble(0)));
return;
}
case COMMAND_NEXT_VIDEO: {
Expand Down Expand Up @@ -88,11 +88,11 @@ public void receiveCommand(YouTubeView view, int commandType, @Nullable Readable
);
}

public int getCurrentTime(YouTubeView view) {
public float getCurrentTime(YouTubeView view) {
return view.getCurrentTime();
}

public int getDuration(YouTubeView view) {
public float getDuration(YouTubeView view) {
return view.getDuration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void currentTime(final int reactTag, final Promise promise) {
public void execute (NativeViewHierarchyManager nvhm) {
YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag);
YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag);
int currentTime = youTubeManager.getCurrentTime(youTubeView);
float currentTime = youTubeManager.getCurrentTime(youTubeView);
promise.resolve(currentTime);
}
});
Expand All @@ -68,7 +68,7 @@ public void duration(final int reactTag, final Promise promise) {
public void execute (NativeViewHierarchyManager nvhm) {
YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag);
YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag);
int duration = youTubeManager.getDuration(youTubeView);
float duration = youTubeManager.getDuration(youTubeView);
promise.resolve(duration);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public void onBuffering(boolean buffering) {
}

@Override
public void onSeekTo(int i) {
mYouTubeView.didChangeToSeeking(i);
public void onSeekTo(int newPositionMillis) {
mYouTubeView.didChangeToSeeking(newPositionMillis);
}

@Override
Expand Down Expand Up @@ -157,16 +157,16 @@ public void onError(YouTubePlayer.ErrorReason errorReason) {
mYouTubeView.receivedError(errorReason.toString());
}

public void seekTo(int second) {
if (isLoaded()) mYouTubePlayer.seekToMillis(second * 1000);
public void seekTo(float second) {
if (isLoaded()) mYouTubePlayer.seekToMillis((int)(second * 1000));
}

public int getCurrentTime() {
return mYouTubePlayer.getCurrentTimeMillis() / 1000;
public float getCurrentTime() {
return mYouTubePlayer.getCurrentTimeMillis() / 1000.f;
}

public int getDuration() {
return mYouTubePlayer.getDurationMillis() / 1000;
public float getDuration() {
return mYouTubePlayer.getDurationMillis() / 1000.f;
}

public void nextVideo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
}

public void seekTo(int second) {
public void seekTo(float second) {
mYouTubeController.seekTo(second);
}

public int getCurrentTime() {
public float getCurrentTime() {
return mYouTubeController.getCurrentTime();
}

public int getDuration() {
public float getDuration() {
return mYouTubeController.getDuration();
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public void playerViewDidBecomeReady() {
public void didChangeToSeeking(int milliSeconds) {
WritableMap event = Arguments.createMap();
event.putString("state", "seeking");
event.putInt("currentTime", milliSeconds / 1000);
event.putDouble("currentTime", milliSeconds / 1000.0);
event.putInt("target", getId());
ReactContext reactContext = getReactContext();
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "state", event);
Expand Down