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

feat: add looping prop to IVSPlayer #142

Merged
merged 1 commit into from
Jul 13, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte
player?.isMuted = muted
}

fun setLooping(shouldLoop: Boolean) {
player?.setLooping(shouldLoop)
}

fun setVolume(volume: Double) {
player?.setVolume(volume.toFloat())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class AmazonIvsViewManager : SimpleViewManager<AmazonIvsView>() {
view.setStreamUrl(streamUrl);
}

@ReactProp(name = "loop")
fun setLooping(view: AmazonIvsView, shouldLoop: Boolean){
view.setLooping(shouldLoop);
}

@ReactProp(name = "resizeMode")
fun setResizeMode(view: AmazonIvsView, mode: String) {
view.setResizeMode(mode);
Expand Down
1 change: 1 addition & 0 deletions example/src/screens/AdvancedExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function AdvancedExample() {
<IVSPlayer
ref={mediaPlayerRef}
autoplay={false}
loop
paused={paused}
streamUrl={URL}
onDurationChange={setDuration}
Expand Down
1 change: 1 addition & 0 deletions ios/AmazonIvsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@interface RCT_EXTERN_MODULE(AmazonIvsManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString)
RCT_EXPORT_VIEW_PROPERTY(muted, BOOL)
RCT_EXPORT_VIEW_PROPERTY(loop, BOOL)
Copy link
Contributor

@dawhitla dawhitla Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, matches loop from <video /> element.

RCT_EXPORT_VIEW_PROPERTY(liveLowLatency, BOOL)
RCT_EXPORT_VIEW_PROPERTY(quality, NSDictionary)
RCT_EXPORT_VIEW_PROPERTY(initialBufferDuration, double)
Expand Down
7 changes: 7 additions & 0 deletions ios/AmazonIvsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AmazonIvsView: UIView, IVSPlayer.Delegate {

override init(frame: CGRect) {
self.muted = player.muted
self.loop = player.looping
self.liveLowLatency = player.isLiveLowLatency
self.autoQualityMode = player.autoQualityMode
self.playbackRate = Double(player.playbackRate)
Expand Down Expand Up @@ -100,6 +101,12 @@ class AmazonIvsView: UIView, IVSPlayer.Delegate {
self.addProgressObserver()
}
}

@objc var loop: Bool {
didSet {
player.looping = loop
}
}

@objc var muted: Bool {
didSet {
Expand Down
1 change: 1 addition & 0 deletions src/IVSPlayer.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare type Props = {|
style?: ViewStyleProp,
paused?: boolean,
muted?: boolean,
loop?: boolean,
autoplay?: boolean,
streamUrl?: string,
resizeMode?: ResizeMode,
Expand Down
4 changes: 4 additions & 0 deletions src/IVSPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type IVSPlayerProps = {
testID?: string;
ref: any;
muted?: boolean;
loop?: boolean;
liveLowLatency?: boolean;
playbackRate?: number;
streamUrl?: string;
Expand Down Expand Up @@ -79,6 +80,7 @@ type Props = {
testID?: string;
paused?: boolean;
muted?: boolean;
loop?: boolean;
autoplay?: boolean;
streamUrl?: string;
liveLowLatency?: boolean;
Expand Down Expand Up @@ -125,6 +127,7 @@ const IVSPlayerContainer = React.forwardRef<IVSPlayerRef, Props>(
streamUrl,
paused,
muted,
loop = false,
resizeMode,
autoplay = true,
liveLowLatency,
Expand Down Expand Up @@ -333,6 +336,7 @@ const IVSPlayerContainer = React.forwardRef<IVSPlayerRef, Props>(
<IVSPlayer
testID="IVSPlayer"
muted={muted}
loop={loop}
liveLowLatency={liveLowLatency}
style={styles.mediaPlayer}
ref={mediaPlayerRef}
Expand Down