React Native Video replay from beginning - ios

I've been using the React Native Video module and its working great, however I need the video on playback end to automatically rewind back to the beginning. The video instance has the option to use:
onEnd={this.onEnd}
To call a function when video playback finishes, and also seems to have this function:
seek(seconds)
But I'm not sure how its used exactly. I need to set the video to 0 time index at playback end.

If you want to start playback again immediately, you can you use the 'repeat' property. If you really just want to reset it without playing, then you need to use seek(). But as far as I know the video component doesn't expose the seek function of the underlying video player directly, but via it's refs. You can use
myVideo.refs.node.seek(0)
where myVideo is a reference to your video component.

Related

AVPlayer or AVQueuePlayer during iPhone Call

I have an app that uses AVPlayer (or AVQueuePLayer) to play local files that were recorded by the App. All works great. But I also want this to work on iPhone when a call is in progress (the videos are event recordings). What I found is that during a phone call, the video feed to avplayerLayer goes blank, AVPlayer rate change to 0 (STOP), and all attempts to change rate to non-zero (PLAY) are ignored (rate stays at 0). There does not appear to be any documentation on this, and the only way to detect this condition in the player, is that player is STOPPED and will not start PLAYBACK. Of course, I also check for audio interruptions, and call center calls in progress.
Obviously, in this case the interruption is caused by a call, so there is always a inactive/resume or a intactive/background/foreground/resume transition. As well as audio route notification, audio interruption. So indirectly I know the condition is probably occurring.
So questions are:
(1) Is there any direct method (specific to AVPlayer,AVPlayerLayer) to be notified that AVPlayer is in this non-playing mode. I now use "avplayer.rate failed to change rate from 0 to non-zero", but this seems hacky (and too much "crossing the streams"!) I want to Notify user that video temporarily can not be played or previewed, so they do not think the App is broken. And also inform them or automatically continue Playback when iPhone call ends. (Without a looping process that keeps trying to start playback every 500ms!)
(2) Can AVPlayer play anything while a iPhone call (Green Bar) is in progress? or is this just the way apple designed the AVPlayer SDK? (If so there is no documentation on this) Obviously, other apps can play video during an iPhone call, but I suspect they are using a lower level SDK and not AVPlayer.

Use javascript to detect if a youtube video is having trouble loading and playing

Is it possible, using javascript, to detect if an embedded youtube video pauses playback in order to let the video buffer? I know that there are events that fire when the user presses pause, but I'm looking for an event that fires when the video pauses due to a slow connection. I'm creating a web application where it's important to have the video play through smoothly. If the video pauses due to a slow connection, I want to detect that.
Use this code player.getPlayerState():Number it seems like you are allowed to ask the player what status it is in so this may help you
https://developers.google.com/youtube/js_api_reference
There is also a state 'buffering' being fired when the player needs to buffer more data..in that case the video stops. I guess also 'error' state might be of help.
The solution I worked out is just to use the javascript API's onStateChange callback (https://developers.google.com/youtube/js_api_reference) to detect when the player is started for the first time and when it finishes playing at the end. When the player is started, I grab the current time. When it finishes, it sees how much time has elapsed. In my application, the user cannot pause the video, so comparing the elapsed time to the video length indicates if it paused for loading.

Reducing the initial delay when playing remote video content

Hi using MPMoviePlayerController to stream video into the app. However, it takes a long time to load and I want to be able to pre-buffer the video. Any suggestions?
Use
[MPMoviePlayerControllerInstance prepareToPlay]
as soon as you know that the user
might start playback of a movie. You
might also want set
MPMoviePlayeController.autoPlay to
something that fits best, depending
on your application.
From Apple's Documentation;
This method is called
automatically when you call the play
method. Calling it before you call
play gives the receiver a chance to
prepare items sooner and may result in
decreased latency when starting
playback. However, calling this method
may also interrupt any active audio
sessions.
Make sure your HTTP stream contains
a low bandwidth alternative using
less than 64Kbps (audio and video combined). Note that the
MPMoviePlayerController usually
starts buffering the low rate
playback index profile before
raising the bar and attempting to
load higher bandwidth profiles. It
will be prepared to play once it has
a few seconds worth of movie data.
Use the
MPMoviePlayerController.movieSourceType
property when initializing your
player to cut down the media
recognition delay.
From the MPMoviePlayerController
Class Reference:
The default value of this property is
MPMovieSourceTypeUnknown. This
property provides a clue to the
playback system as to how it should
download and buffer the movie content.
If you know the source type of the
movie, setting the value of this
property before playback begins can
improve the load times for the movie
content. If you do not set the source
type explicitly before playback, the
movie player controller must gather
this information, which might delay
playback.

Movie is played with some delay after calling play on MPMoviePlayerController

I am developing an iPhone application in which I play the videos using MPMoviePlayerController. Sometimes, some of the videos does not play immediately after I call play on MPMoviePlayerController.
I have called prepareToPlay and in the notified method of MPMediaPlaybackIsPreparedToPlayDidChangeNotification, I am calling play on MPMoviePlayerController.
How can I identify the problem here?
Try using the property movieSourceType and assign a proper value to it before running prepareToPlay.
From MPMoviePlayerController reference;
The default value of this
property is MPMovieSourceTypeUnknown.
This property provides a clue to the
playback system as to how it should
download and buffer the movie content.
If you know the source type of the
movie, setting the value of this
property before playback begins can
improve the load times for the movie
content. If you do not set the source
type explicitly before playback, the
movie player controller must gather
this information, which might delay
playback.

GaugeField progress forward and rewind when playing audio?

I'm developing a player Application which plays audio for some fixed time. I need to use Gaugefield such that it should fast-forward and rewind the Audio that is currently Playing.
I am able to get the time from the player and displaying on the screen. I need to update the time when the progress of Gaugefield is increased or decreased and at the same time I need to stream the player according to the level of the Gaugefield.
I used the sample code below but it is not working.
Player.stop();
Player.setMediaTime();
Player.start();
I am working on 6.0 OS.
Are you implementing a PlayerListener? If you implement PlayerListener, then you can use the playerUpdate() method to update your GaugeField.

Resources