You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Exoplayer team,
I am using Exoplayer 2 in my video player for playback and I am looking for a mechanism through which I can instruct exoplayer to stop at certain position in advance. Let me explain what exactly I am looking here.
We get a seamless HLS stream which has video content and ads content. Along with stream as a response from the server, we also get ads position for playing the ads i.e. at which playhead position ads are present. We need these positions as we show different UI controls when ads are playing. So for example, I would have something like this as ads position in milliseconds.
I have a scheduler which polls for getCurrentPosition. Everything seems to work perfectly fine apart from one issue. When I do a seek while the video is playing and if there is an ad interval in between those seeking positions, I am supposed to trigger the ads and once ads are completed, I seeked to the desired position. Here comes the problem, after the ads end,I see the first frame of content. Exoplayer gives positions as,
TimePosition(622593)
TimePosition(623138)
What I am looking here is, if somehow I can pause/stop exoplayer at a certain position which in this case would be end=TimePosition(623094).
I never want exoplayer to go beyond end=TimePosition(623094) in this case. Please suggest what can be the right solution here.
The text was updated successfully, but these errors were encountered:
abhishekredspace
changed the title
How to get next position along with current position?
How to instruct exoplayer to stop at a certain position in advance?
Apr 24, 2018
I understand the problem. I don't think we have a frame accurate solution to this currently, although it should be possible to do better than your polling approach. You can use an event based approach as follows:
Define a component that will be called whenever a boundary between content and ad is reached:
PlayerMessage.Target boundaryHandler = new PlayerMessage.Target() {
@Override
public void handleMessage(int messageType, Object payload) {
long boundaryPositionMs = (long) payload;
// TODO: Implement your logic here.
}
};
Ask the player to call your component whenever a boundary between content and ad is reached. For each boundary position, do:
You should then see handleMessage invoked whenever a boundary is hit, and you can take appropriate action there. This wont be frame accurate, unfortunately, due to the way ExoPlayer works internally, but it should get you closer to what you need, and is definitely better than polling.
There are variations on the suggested approach above, where you only ask the player to call you back for a single position of interest, don't ask for message re-delivery etc, so you can play around with the idea.
I think the "proper" solution to this would be to implement a variant of AdsMediaSource that operates on a single child MediaSource plus a list of known ad positions. That's a pretty involved change, however.
Let us know how you get on with the approach above! We can probably turn this issue into an enhancement request for the "proper" solution, but I don't think we'll have time to look at it soon.
Hi Exoplayer team,
I am using Exoplayer 2 in my video player for playback and I am looking for a mechanism through which I can instruct exoplayer to stop at certain position in advance. Let me explain what exactly I am looking here.
We get a seamless HLS stream which has video content and ads content. Along with stream as a response from the server, we also get ads position for playing the ads i.e. at which playhead position ads are present. We need these positions as we show different UI controls when ads are playing. So for example, I would have something like this as ads position in milliseconds.
TimeInterval{start=TimePosition(532673), end=TimePosition(623094)}
I have a scheduler which polls for
getCurrentPosition
. Everything seems to work perfectly fine apart from one issue. When I do a seek while the video is playing and if there is an ad interval in between those seeking positions, I am supposed to trigger the ads and once ads are completed, I seeked to the desired position. Here comes the problem, after the ads end,I see the first frame of content. Exoplayer gives positions as,TimePosition(622593)
TimePosition(623138)
What I am looking here is, if somehow I can pause/stop exoplayer at a certain position which in this case would be end=TimePosition(623094).
I never want exoplayer to go beyond end=TimePosition(623094) in this case. Please suggest what can be the right solution here.
The text was updated successfully, but these errors were encountered: