We are trying play audio from url (m3u8 file). Media player starts fine no issues. Audio also plays cleanly. Issue starts when do seek in the player. Behavior very strange. it seeks to the proper position then starts playing audio. After while it seeks again like couples seconds (better word is skips some seconds since it jumps to the position directly) and can be observed in the media playback time counter, again plays for a while again jumps some seconds and this continues till end of the media.
We have our custom seek bar which is nothing but a progressbar, and when we do seek the progress bar we send same seek position to media player by calling onseek() method.
Note: Issue Happens only Lollipop nexus devices(tablet and phone).
Strange observation jump happens only if the time counters last position 9
(i.e if mediaplayed 12:29[mm:ss] then will jump to some other random place 12:3X[mm:ss],again mediaplayed 12:39[mm:ss] then will jump to some other random place 12:4X [mm:ss] )
Why is it happening?
You should pass the outer manifest to the player. This should resolve your issue.
Related
I want to change current playing video to another seamlessly. But there is a little bit delay before the next video will be playing. I don't know what the next video will be. How I can do this?
You can use playlists with ExoPlayer. This way the playback transitions at the end of item 1 to 2 without buffering.
DynamicConcatenatingMediaSource mainSource = new DynamicConcatenatingMediaSource();
mainSource.addMediaSource(mediaSource1);
player.prepare(mainSource);
// later...
mainSource.addMediaSource(mediaSource2);
As soon as you know the second media you can add it while the player is playing.
https://medium.com/google-exoplayer/dynamic-playlists-with-exoplayer-6f53e54a56c0
My app needs to record video with a maximum time of 8 seconds. This is already implemented with MediaRecorder.setMaxDuration(long milliseconds).
The app also needs a progress bar in the top and a label with a count down of the remaining time.
The problem here is that there's an offset between the UI and the MediaRecorder progress, and this leads to confusion in the user. For example, the user thinks that he/she recorded something because the progress in the UI said so, but the media recorder cut off the video a second earlier.
The challenge is to start the progress bar and counter at the exact same time as the recorder actually starts recording.
I've tried starting the timer after MediaRecorder.start(), in a callback when the created file is modified for the first time, but I haven't found a way to achieve this in a correct way. We tried setting a hard coded offset to these values but of course it didn't work the same for every device.
I wish there was a callback from the MediaRecorder to inform that it has actually started to record the video, or maybe the current length.
Is the problem clear? Has someone solved this before?
MediaRecorder has known issues with cutting off audio early. I implemented a recorder with a button - clicking the button to stop the recorder would actually yield an audio file with the last second cut off.
Not sure if your UI offset is a separate issue, but I would try extending the MediaRecorder by half a second after the user attempts to end it. You can either do this by changing the maximum time to 8.5 seconds, or just using this line of code:
android.os.SystemClock.sleep(500);
In Titanium, When the window opens the sound should autoplay . Sometimes it does but mostly it doesnt and sometimes it plays for a millisecond. As the hund.js opens the sound should play.
I have checked the mp3clips and there is nothing wroing with them.
the soundbit: http://pastie.org/8729002
the full code for the win + soundbit: http://pastie.org/8729003
Im new to programming so I really cant figure this out.
Try moving player.play(); to the very bottom after hundwin.open();
The hundview may be taking focus away from your global player.
I'm working on an app in which the video is paused at 3 different intervals. After the second pause, if a button is clicked, it should start back from the previous location.
Eg. if it is currently paused at 1:30, then on click of a button, it goes to the previous bookmark, i.e. 00:45.
I thought using MediaPlayer.seekTo() will help me achieve this. But, seekTo() doesn't seek the position at all. The currentPosition stays the same even after a call to seekTo();
Here's my code.
mediaPlayer.setOnSeekCompleteListener(new OnSeekCompleteListener() {
#Override
public void onSeekComplete(MediaPlayer mp) {
Log.d("VID_PLAYER","Seek Complete. Current Position: " + mp.getCurrentPosition());
mp.start();
}
});
and somewhere below, I have this...
mediaPlayer.seekTo(45000);
What is the problem? Why isn't seekTo(); working?
Any help would be appreciated.
I am currently testing it on Android v4.0.3 (ICS)
Try the code snippet given below to achieve more accuracy in seeking to specific positions of the media.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
mediaPlayer.seekTo(seekPosition,MediaPlayer.SEEK_CLOSEST);
else
mediaPlayer.seekTo((int)seekPosition);
Keep in mind that - as the accuracy increases, speed of seeking decreases. So while playing high resolution videos its advised not to use MediaPlayer.SEEK_CLOSESTmore often.
One of the reasons why Android is not able to do seekTo is because of strange encoding of the videos. For example in MP4 format so called "seek points" (i.e. search index) can be specified at the begining and at the end of the file. If they are specified at the begining of the file then seekTo will behave correctly. But if they are specified at the end of the file then seekTo will do nothing and video will start from the begining after seekTo.
This is confirmed bug-or-feature in Android 4.4.2.
P.S. On Youtube all videos are encoded with "seek points" at the begining of the file. So if you have this problem with seekTo in your app first of all check your app with some video files from Youtube. Perhaps you'll need to reencode your videos...
Does your problem have something to do with this bug:
https://code.google.com/p/android/issues/detail?id=4124
I recall encountering this about a year ago. I don't think I found a workaround at the time.
Since API 26, Android added a
seekTo(long msec, int mode);
By specifying a mode, we are able to tell to our MediaPlayer how to seek:
SEEK_PREVIOUS_SYNC: Has the same behavior as seekTo(int msec). It looks for the nearest 'seek point' (i.e. sync frame) backwards.
SEEK_NEXT_SYNC: Same as PREVIOUS, but looks forwards.
SEEK_CLOSEST_SYNC: This looks for the nearest sync frame given a msec time.
SEEK_CLOSEST: This seeks for the nearest frame given a msec time.
I faced a similar problem a couple days ago and by using SEEK_CLOSEST mode, this problem was solved.
For reference, check out these links: https://developer.android.com/reference/android/media/MediaPlayer.html#seekTo(long,%20int)
https://en.wikipedia.org/wiki/Video_compression_picture_types
I am creating a program which requires me to change a setting in the program when the video reaches specific points (at 1/3 of the video's completion, 2/3's and on completion). Android has a built in callback method for completion so performing an action at that point in time is not difficult. However, I don't know how to go about checking when the video has reached 1/3 and 2/3's of completion.
Using a MediaPlayer control you will get
the total duration of your media file in milliseconds:
myMediaPlayer.getDuration()
you will implement a thread that check every second for the current position at 1/3, 2/3 and 3/3 of the videos completion, with
myMediaPlayer.getCurrentPosition(); //***current Position in milliseconds.