Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): expose videoPlayer buffer #13727

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ public boolean onError(MediaPlayer mp, int framework_err, int impl_err)
public void onBufferingUpdate(MediaPlayer mp, int percent)
{
mCurrentBufferPercentage = percent;
if (mPlaybackListener != null) {
mPlaybackListener.onBuffer(percent);
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface TiPlaybackListener {
void onSeekingBackward();

void onSeekingForward();

void onBuffer(int value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ public void onSeekingForward()
getPlayerProxy().onSeekingForward();
}

@Override
public void onBuffer(int value)
{
getPlayerProxy().onBuffer(value);
}

@Override
public void onSeekingBackward()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,13 @@ public void onSeekingBackward()
firePlaybackState(MediaModule.VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD);
}

public void onBuffer(int value)
{
KrollDict kd = new KrollDict();
kd.put("percentage", value);
fireEvent("buffer", kd);
}

private String getActionName(int action)
{
switch (action) {
Expand Down
10 changes: 10 additions & 0 deletions apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ methods:
summary: Stops playing the video.

events:
- name: buffer
summary: |
Fired when the video is loading/buffering.
properties:
- name: percentage
summary: Percentage of the video that is buffered/loaded.
type: Number
since: '12.1.0'
m1ga marked this conversation as resolved.
Show resolved Hide resolved
platforms: [android]

- name: complete
summary: Fired when movie playback ends or a user exits playback.
description: |
Expand Down