From 00fe87a2abefea7faca75888205a70a0a34b4ed4 Mon Sep 17 00:00:00 2001 From: Rafael Pinto Date: Tue, 5 Jun 2018 23:04:20 +0100 Subject: [PATCH] replaced channel with stereoPan attribute --- README.md | 2 +- Video.js | 2 +- .../exoplayer/ReactExoplayerView.java | 4 +-- .../exoplayer/ReactExoplayerViewManager.java | 6 ++-- .../com/brentvatne/react/ReactVideoView.java | 30 ++++++++++++------- .../react/ReactVideoViewManager.java | 8 ++--- 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4697e990..0266a1d1 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ using System.Collections.Generic; }} // Store reference rate={1.0} // 0 is paused, 1 is normal. volume={1.0} // 0 is muted, 1 is normal. - channel="both" // [Android only] Target channel for audio panning: left, right or both (default). + stereoPan={0} // [Android only] The audio player’s stereo pan position. A value of –1.0 is full left, 0.0 is center, and 1.0 is full right. Default 0.0 muted={true|false} // Mutes the audio entirely. Default false paused={true|false} // Pauses playback entirely. Default false resizeMode="cover" // Fill the whole screen at aspect ratio.* diff --git a/Video.js b/Video.js index 0510f416..40216f8b 100644 --- a/Video.js +++ b/Video.js @@ -277,7 +277,7 @@ Video.propTypes = { paused: PropTypes.bool, muted: PropTypes.bool, volume: PropTypes.number, - channel: PropTypes.string, + stereoPan: PropTypes.number, rate: PropTypes.number, playInBackground: PropTypes.bool, playWhenInactive: PropTypes.bool, diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 6ccce609..11296fdd 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -650,9 +650,9 @@ class ReactExoplayerView extends FrameLayout implements } } - public void setChannel(String channel) { + public void setStereoPan(float stereoPan) { if (player != null) { - player.setChannel(channel); + player.setStereoPan(stereoPan); } } diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index 161a3648..c15b59c1 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -132,9 +132,9 @@ public class ReactExoplayerViewManager extends ViewGroupManager 0) { + // louder on the right channel + setVolume(calulateRelativeVolume(), mVolume); } else { + // same volume on both channels setVolume(mVolume, mVolume); } } @@ -387,8 +395,8 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP setMutedModifier(mMuted); } - public void setChannel(final String channel) { - mChannel = channel; + public void setStereoPan(final float stereoPan) { + mStereoPan = stereoPan; setMutedModifier(mMuted); } diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java b/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java index 3f29d417..eff426a2 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java @@ -30,7 +30,7 @@ public class ReactVideoViewManager extends SimpleViewManager { public static final String PROP_PAUSED = "paused"; public static final String PROP_MUTED = "muted"; public static final String PROP_VOLUME = "volume"; - public static final String PROP_CHANNEL = "channel"; + public static final String PROP_STEREO_PAN = "stereoPan"; public static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval"; public static final String PROP_SEEK = "seek"; public static final String PROP_RATE = "rate"; @@ -125,9 +125,9 @@ public class ReactVideoViewManager extends SimpleViewManager { videoView.setVolumeModifier(volume); } - @ReactProp(name = PROP_CHANNEL) - public void setChannel(final ReactVideoView videoView, final String channel) { - videoView.setChannel(channel); + @ReactProp(name = PROP_STEREO_PAN) + public void setStereoPan(final ReactVideoView videoView, final float stereoPan) { + videoView.setStereoPan(stereoPan); } @ReactProp(name = PROP_PROGRESS_UPDATE_INTERVAL, defaultFloat = 250.0f)