I can't seem to find how to set a duration time for the slides, the original timing is to slow for me.
I read that I have to use $Idle, but I don't know where and how
Thanks for helping!
var jssor_1_options = {
$Idle: 2000 //in milliseconds
};
Related
I am using the Flutter video_player package here: https://pub.dev/packages/video_player
How do I get the duration of the video? I can see there is a position property, so I would need that to get the current value in time.
But how do I get the total duration of the video? The video is from a URL.
I am making a custom player so I need these two values.
For getting the Total duration you can use the video controller
VideoPlayerController _controller = VideoPlayerController.network('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
});
Duration durationOfVideo = _controller.value.duration;
You can also directly store the integer instead of duration as below image
You can create a function to calculate the video Dutarion and format it.
getVideoPosition() {
var duration = Duration(milliseconds: videoController.value.position.inMilliseconds.round());
return [duration.inMinutes, duration.inSeconds].map((seg) => seg.remainder(60).toString().padLeft(2, '0')).join(':');
}
After craeate this function, you just need to call it to show the duration.
Ex.:
Text(getVideoPosition())
The following code from here shows how to do a fade-out for NSView in Swift:
NSAnimationContext.runAnimationGroup({ context in
context.duration = 1
self.view.animator().alphaValue = 0
}, completionHandler: {
self.view.isHidden = true
self.view.alphaValue = 1
})
I am using this code to display a status notification -> i.e. the text appears, stays for around a few seconds, and then fades out. Is there a way to delay the start of the fade out to accomplish this?
Is there a way to delay the start of the fade out to accomplish this?
One way is to use NSTimer to run your animation after whatever delay you choose. For example, you could pass a block containing your code to +scheduledTimerWithTimeInterval:repeats:block:, and once the interval expires the block will run.
Im having a problem with seeking with AVPlayer.seekToTime, I have the time index that I want to seek to inside a scrollViewDidScroll method like this:
func scrollViewDidScroll(scrollView: UIScrollView) {
let offsetTime = scrollView.contentOffset.y * 0.1
self.playerController.player?.seekToTime(CMTime(seconds: Double(offsetTime), preferredTimescale: 10), toleranceBefore: kCMTimePositiveInfinity, toleranceAfter: kCMTimeZero)
}
But the video does not flow nice. For example, when you scroll I want the video to only to move forward like 0.01 of a second (the video I have is real short only about 2.0 sec long) but when you scroll far enough, instead the video moves forward almost a whole second. Its really choppy and I'm not sure why I can't seek to like say 1.00 seconds to 1.01 seconds and have the image representing the time index on the player move. Is this possible? What am I doing wrong? Please help!
PS: I never call self.playerController.player?.play() if this helps
Maybe your tolerance before is not set right. try the Following:
instead of your code:
let offsetTime = scrollView.contentOffset.y * 0.1
let seekTime : CMTime = CMTimeMake(Double(offsetTime), 1000)
self.playerController.player?.seekToTime(seekTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
the Time Scale tells how many units you have per second
Also, toleranceBefore should ALSO be kCMTimeZero
hope this Helps :-)
Hey I tried the above code in a Xamarin project using Octane.Xam.Videoplayer: https://components.xamarin.com/view/video-player
It worked really well!
Here is my sample code which I put into a Custom Renderer that inherited from VideoPlayerRenderer which can be found in the namespace Octane.Xam.VideoPlayer.iOS.Renderers:
public void CustomSeek(int seekTime)
{
CMTime tm = new CMTime(seekTime, 10000);
if(NativeVideoPlayer.Player != null)
NativeVideoPlayer.Player.Seek(tm, CMTime.Zero, CMTime.Zero);
}
Keep in mind that you will have to use Version 1.1.4 of the Octane.Xam.VideoPlayer to gain access to the NativeVideoPlayer property of the VideoPlayerRenderer. In the future this property may be renamed to PlayerControl.
I have an application that adds one to the score whenever you tap anywhere on the view. I would like to have a score multiplier that states that whenever the user is tapping faster his or her score will not just increment by one, but by a larger amount depending on how fast and/or how long they have been tapping. I've done a good bit of Googling but I have yet to find anything. Thanks in advance
Without further examples its hard to actually give you help, here is a stab
static let multiplier = 1000
struct Player {
var score: Int
var displayScore: Int {
return score * multiplier
}
}
var player = Player(score: 1)
print(player.displayScore) // 1000
player.score += 1
print(player.displayScore) // 2000
While using MPMoviePlayerController is there any way to find how much Percentage of data finished while buffering the video?
My aim is to show the progress bar that showing how much percentage is loaded and show its numeric count of percentage.
Thanks in advance.
Have you checked out the Apple documentation for the MPMoviePlayerController ?
http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html
Here you can find two properties that might help you. duration and playableDuration, it's not an exact fit, but pretty close. One thing you will need to implement yourself is a way to intelligently query these properties, for example maybe you might want to use an NSTimer and fetch the info from your MPMovePlayerController instance every 0.5 seconds.
For example assume you have a property called myPlayer of type MPMoviePlayerController, you will initiate it in your init method of the view controller etc...
Then followed by this:
self.checkStatusTimer = [NSTimer timerWithTimeInterval:0.5
target:self
selector:#selector(updateProgressUI)
userInfo:nil
repeats:YES];
And a method like this to update the UI:
- (void)updateProgressUI{
if(self.myPlayer.duration == self.myPlayer.playableDuration){
// all done
[self.checkStatusTimer invalidate];
}
int percentage = roundf( (myPlayer.playableDuration / myPlayer.duration)*100 );
self.progressLabel.text = [NSString stringWithFormat:#"%d%%", percentage];
}
Note the double percentage sign in our -stringWithFormat, this is another format specifier to resolve to a % sign. For more on Format specifiers see here.