Skip to content

Commit

Permalink
feat: add looping prop to IVSPlayer (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnovick authored Jul 13, 2023
1 parent febe3ac commit e41bfb3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
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)
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

0 comments on commit e41bfb3

Please sign in to comment.