I have a wkWebView where I display a video. How can I automatically switch to the next screen after the video ends?
It doesn't look like WKWebView has any call back methods to notify when a video has completed. The only suggestions I can provide is if the video lives locally in the app, you can use AVFoundation and take advantage of their call back methods. Other users have also mentioned using Javascript to detect when an online video has finished.
I'm using GoogleVR library for iOS to play VR video. I use GVRVideoView. But there is a problem that I don't know how to get current play time. I need to show a Slider on UI, that includes current play time.
https://developers.google.com/vr/ios/get-started
So, how can I get current play back time of GVRVideoView?
GVRVideoView has a delegate method
- (void)videoView:(GVRVideoView*)videoView didUpdatePosition:(NSTimeInterval)position;
You can do with the position, for example, set progress with position/videoView.duration.
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.
My website is running Bootstrap 3.0 and I have an intro video and full length video hosted on YouTube that I am trying to implement. The intro video autoplays when the page is loaded, and then I have a button that opens up a modal window with the full video with audio.
I would like to stop the video completely on close of the modal window so that if they click the button to open it again, the video starts from the beginning. Unfortunately, the stopVideo function doesn't seem to be working how I would expect. Basically, it's just pausing the video, so if I open the modal back up, the video starts playing right from where it left off.
How can I make it so that the video stops and starts from the beginning if it's reopened?
Here is my current code:
$('#myModal').on('show.bs.modal', function () {
$('#placeholder')[0].contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
$('#full')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*');
});
$('#myModal').on('hidden.bs.modal', function () {
$('#full')[0].contentWindow.postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '*');
$('#placeholder')[0].contentWindow.postMessage('{"event":"command","func":"' + 'playVideo' + '","args":""}', '*');
});
Thanks!
You can use seekTo to get back to the begining of the video when the modal is open.
An play the video after the seekTo
Doc from API
player.seekTo(seconds:Number, allowSeekAhead:Boolean):Void
Seeks to a specified time in the video. If the player is paused when
the function is called, it will remain paused. If the function is
called from another state (playing, video cued, etc.), the player will
play the video. The seconds parameter identifies the time to which the
player should advance.
The player will advance to the closest keyframe before that time
unless the player has already downloaded the portion of the video to
which the user is seeking. In that case, the player will advance to
the closest keyframe before or after the specified time as dictated by
the seek() method of the Flash player's NetStream object. (See Adobe's
documentation for more information.)
The allowSeekAhead parameter determines whether the player will make a
new request to the server if the seconds parameter specifies a time
outside of the currently buffered video data.
We recommend that you set this parameter to false while the user drags
the mouse along a video progress bar and then set it to true when the
user releases the mouse. This approach lets a user scroll to different
points of a video without requesting new video streams by scrolling
past unbuffered points in the video. When the user releases the mouse
button, the player advances to the desired point in the video and
requests a new video stream if necessary.
I also encountered this problem,spend hours digging into it. however I didn't find a sure reason, but the following reason may be it:
("stopVideo()") Stops and cancels loading of the current video.
and
Important: Unlike the pauseVideo function, which leaves the player in the paused (2) state, the stopVideo function could put the player into any not-playing state, including ended (0), paused (2), video cued (5) or unstarted (-1).
This is quoted from the YouTube API page
But I'm confused by this, because even if the background mechanism are not the same between stop and pause api, they act still identical(sometimes), so I'm still confused and curious about the real usage of stopVideo().
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.