I am geting a HLS stream video which has to be played part by part and between the parts I should show some animations.
For example the first part has 19.2 seconds duration. What will be the best way to schedule exoplayer to pause after exact duration ?
Currently I am using a handler to pause after exact duration, which of course is not a good solution, because we may have case when video is not loaded.
One way is to use ClippingMediaSource. Google it and see if it suits you.
Related
I am trying to achieve smooth video scrubbing with Android VideoView. The seekTo method of MediaPlayer is not doing exactly what i want. It does not exactly seek to millisecond i passed in it, it actually plays from/jumps to the nearest position, not the exact I seeked to. Also the frames are showing with a large gaps. Not the exact frame for millisecond.
I came on searching around and found that SEEK_CLOSEST_SYNC can only seek to the nearest sync frame not the EXACT. It depends on the way the video was generated.
How can i achieve the smooth scrubbing and seek to exact position Even video is paused or playing. Is it possible through Android VideoView or MediaPlayer class or should i change the approach?
This is not a straight forward question to answer. I spent a month researching and implementing it myself.
The only way this can be achieved is using MediaCodec.
You can look at this project that does exact scrubbing using MediaCodec. The only issue I had with that project is that it takes time to load the buffer and display it on the surface, about 0.5 seconds.
You can also have a look at Grafica, especially the MoviePlayer class. Another source is the BigFlake website.
What I ended up doing is creating my own implementation using MediaCodec as none of them provided me exactly what I was looking for, as I was building a golf analyzer, I needed (real-time) precise (frame-per-frame) scrubbing of the video.
You can also look at a question I asked that is similar to this, where I added a lot of info on how I achieved this. Though this question is more about playing a video frame-per-frame, I think there is valuable info in it.
Has anyone tried using ExoPlayer to achieve this?
I tried looking online with no success.
When I say gapless playback, I am referring to the problem of using the media player to play local videos back to back. After the first video is done playing, there is a noticeable delay of 1 second before the second video starts.
Hoping this question helps in understanding this issue further.
For reference please look at the following question:
Android: MediaPlayer gapless or seamless Video Playing
ExoPlayer 2, which is now officially released, seems to support gapless playback using the ConcatenatingMediaSource class. From its developer guide:
Transitions between sources are seamless. There is no requirement that the sources being concatenated are of the same format (e.g. it’s fine to concatenate a video file containing 480p H264 with one that contains 720p VP9). The sources may even be of different types (e.g. it’s fine to concatenate a video with an audio only stream).
And the example code:
MediaSource firstSource = new ExtractorMediaSource(firstVideoUri, ...);
MediaSource secondSource = new ExtractorMediaSource(secondVideoUri, ...);
// Plays the first video, then the second video.
ConcatenatingMediaSource concatenatedSource =
new ConcatenatingMediaSource(firstSource, secondSource);
EDIT: ExoPlayer 2 supports gapless playback, but as of the time of writing is still unreleased as a stable version.
You will most likely never be able to achieve perfect gapless playback of multiple tracks with ExoPlayer or Android Media Player. Neither have been written to support starting multiple tracks and I imagine it will stay out of scope for both of them.
You can achieve gapless playback by using 2 different player instances, once you have started and played the first, you can load the second and start playback once the first finishes. Using this method you could have a gapless solution, as long as you prepare the second video during playback of the first.
To take it further, you can also use 2 different surface textures for rendering the multiple videos, once the first video reaches the end you could fade out the texture and fade in the new one. Resulting in a nice seamless video effect.
Because of the nature of playing multiple videos at once you will most likely want to create your own timer for incrementing the time and deciding when to switch to the next video, rather than trying to use the callbacks from ExoPlayer or Android Media. This will allow you to keep track of the time in a more accurate fashion, without needing to keep talking to multiple video codecs.
I know this is not the answer you've been looking for, but it's the only reasonable answer. The sole way to ensure no gaps in playback is to download the entire file first and begin playback when it's done. Otherwise, in the event that you lose connectivity before the file is finished downloading, pausing is inescapable.
I just tried switching to ExoPlayer from the standard MediaPlayer implementation and the gap is the same if not worse. However I have used a very simple method of restarting the player when the status changes to ended. I don't know if there's a better proper way to do it, perhaps with 2 different ExoPlayers.
I need a web based video player that provides "time duration for which a user played a video" and "instance at which the video stopped playing".
It would be great if it can provide details like the time at which the video was started (if he has skipped to a certain location when the video has started) and the stop time of the video.
Could anyone please suggest a ready made player available in market which provides all these information OR some alternate approach to achieve the same.
I want to achieve the same for iOS and Android devices. Is this something possible? And if yes please help me on its feasibility with Phonegap?
Thanks in advance
You won't need a speical player for this. The mediaelements audio and video already have a property called played.
I have an app that shows a dancing toy in a VideoView at full screen. Sometimes another video executes over the video of the toy, in this case i have problems with the view because the video of the top shows transparent.
If i set vid1.stopPlayback(); before call the second video, it works, but i cant reproduce the first.
Is there some way to play both videos at same time?
I am not fully certain, but I got a feeling I've read simultaneous video playback may not be possible due to the way it is rendered on the screen. I can't find where I read about this, but you may try searching that way though.
how to fast forwarding an Audio file using media player in android on seekbar progress change?
I would use the 'seekTo()'-method and jump about 10 or 20 seconds each time.
I don't think MediaPlayer can do much more than play/pause actually. I'm using SoundPool non-stop, so someone should correct me if I'm wrong here.
I think you might need to add different versions of the song (with different speed) and change the actual source each time you want to speed up.