From 8b931cbc5d82efec691cabab1b5256435b4b029b Mon Sep 17 00:00:00 2001 From: Rafael Pinto Date: Tue, 5 Jun 2018 02:25:46 +0100 Subject: [PATCH 1/8] Added channel property to allow audio panning --- Video.js | 1 + .../brentvatne/exoplayer/ReactExoplayerView.java | 6 ++++++ .../exoplayer/ReactExoplayerViewManager.java | 6 ++++++ .../java/com/brentvatne/react/ReactVideoView.java | 14 ++++++++++++++ .../brentvatne/react/ReactVideoViewManager.java | 6 ++++++ 5 files changed, 33 insertions(+) diff --git a/Video.js b/Video.js index aced6e55..0510f416 100644 --- a/Video.js +++ b/Video.js @@ -277,6 +277,7 @@ Video.propTypes = { paused: PropTypes.bool, muted: PropTypes.bool, volume: PropTypes.number, + channel: PropTypes.string, 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 aa60ac14..6ccce609 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -650,6 +650,12 @@ class ReactExoplayerView extends FrameLayout implements } } + public void setChannel(String channel) { + if (player != null) { + player.setChannel(channel); + } + } + public void seekTo(long positionMs) { if (player != null) { eventEmitter.seek(player.getCurrentPosition(), positionMs); 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 b500f400..161a3648 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -27,6 +27,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager { 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_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval"; public static final String PROP_SEEK = "seek"; public static final String PROP_RATE = "rate"; @@ -124,6 +125,11 @@ 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_PROGRESS_UPDATE_INTERVAL, defaultFloat = 250.0f) public void setProgressUpdateInterval(final ReactVideoView videoView, final float progressUpdateInterval) { videoView.setProgressUpdateInterval(progressUpdateInterval); From 68dd2a72ba38d6bba6e2adb58b6463d1a01868ab Mon Sep 17 00:00:00 2001 From: Rafael Pinto Date: Tue, 5 Jun 2018 02:48:01 +0100 Subject: [PATCH 2/8] Updated readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 312e5ae0..4697e990 100644 --- a/README.md +++ b/README.md @@ -188,6 +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). 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.* From 00fe87a2abefea7faca75888205a70a0a34b4ed4 Mon Sep 17 00:00:00 2001 From: Rafael Pinto Date: Tue, 5 Jun 2018 23:04:20 +0100 Subject: [PATCH 3/8] 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) From 3ba45a62ffc6cd9eae5c3dbb630b67008170d6f4 Mon Sep 17 00:00:00 2001 From: Rafael Pinto Date: Tue, 5 Jun 2018 23:12:10 +0100 Subject: [PATCH 4/8] Updated incorrect property name --- .../com/brentvatne/exoplayer/ReactExoplayerViewManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c15b59c1..0f8d2732 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -27,7 +27,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Wed, 6 Jun 2018 04:18:07 +0100 Subject: [PATCH 5/8] Revert incorrect exoplayer changes --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 6 ------ .../com/brentvatne/exoplayer/ReactExoplayerViewManager.java | 6 ------ 2 files changed, 12 deletions(-) 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 11296fdd..aa60ac14 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -650,12 +650,6 @@ class ReactExoplayerView extends FrameLayout implements } } - public void setStereoPan(float stereoPan) { - if (player != null) { - player.setStereoPan(stereoPan); - } - } - public void seekTo(long positionMs) { if (player != null) { eventEmitter.seek(player.getCurrentPosition(), positionMs); 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 0f8d2732..b500f400 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -27,7 +27,6 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Wed, 6 Jun 2018 04:36:55 +0100 Subject: [PATCH 6/8] Fixed readme conflict --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 26014b67..48fe27be 100644 --- a/README.md +++ b/README.md @@ -184,13 +184,6 @@ using System.Collections.Generic; ref={(ref) => { this.player = ref }} // Store reference - rate={1.0} // 0 is paused, 1 is normal. - volume={1.0} // 0 is muted, 1 is normal. - 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.* - repeat={true|false} // Repeat forever. Default false playInBackground={true|false} // Audio continues to play when app entering background. Default false playWhenInactive={true|false} // [iOS] Video continues to play when control or notification center are shown. Default false onBuffer={this.onBuffer} // Callback when remote video is buffering @@ -352,6 +345,14 @@ Adjust the volume. Platforms: all +#### stereoPan +The audio player’s stereo pan position. Any value between –1.0 and 1.0 is accepted. +* **-1.0** - Full left +* **0.0 (default)** - Center +* **1.0** - Full right + +Platforms: Android + ### Additional props To see the full list of available props, you can check the [propTypes](https://github.com/react-native-community/react-native-video/blob/master/Video.js#L246) of the Video.js component. From 04cb01fdcb8e17290a3b43a119ce24bc8a0223df Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Thu, 7 Jun 2018 22:51:50 -0700 Subject: [PATCH 7/8] Show stereoPan platform as Android MediaPlayer --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 48fe27be..d074e9aa 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,7 @@ var styles = StyleSheet.create({ * [repeat](#repeat) * [resizeMode](#resizemode) * [selectedTextTrack](#selectedtexttrack) +* [stereoPan](#stereopan) * [volume](#volume) #### ignoreSilentSwitch @@ -337,6 +338,14 @@ If a track matching the specified Type (and Value if appropriate) is unavailable Platforms: Android ExoPlayer, iOS +#### stereoPan +The audio player’s stereo pan position. Any value between –1.0 and 1.0 is accepted. +* **-1.0** - Full left +* **0.0 (default)** - Center +* **1.0** - Full right + +Platforms: Android MediaPlayer + #### volume Adjust the volume. * **1.0 (default)** - Play at full volume @@ -345,14 +354,6 @@ Adjust the volume. Platforms: all -#### stereoPan -The audio player’s stereo pan position. Any value between –1.0 and 1.0 is accepted. -* **-1.0** - Full left -* **0.0 (default)** - Center -* **1.0** - Full right - -Platforms: Android - ### Additional props To see the full list of available props, you can check the [propTypes](https://github.com/react-native-community/react-native-video/blob/master/Video.js#L246) of the Video.js component. From cb9e860cde069d8d663bdb9520ae8a31068473bc Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Thu, 7 Jun 2018 22:53:19 -0700 Subject: [PATCH 8/8] Make stereoPan description a bit more understandable --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d074e9aa..29b876fe 100644 --- a/README.md +++ b/README.md @@ -339,7 +339,7 @@ If a track matching the specified Type (and Value if appropriate) is unavailable Platforms: Android ExoPlayer, iOS #### stereoPan -The audio player’s stereo pan position. Any value between –1.0 and 1.0 is accepted. +Adjust the balance of the left and right audio channels. Any value between –1.0 and 1.0 is accepted. * **-1.0** - Full left * **0.0 (default)** - Center * **1.0** - Full right