Skip to content

Commit

Permalink
feat: modified react exo player android
Browse files Browse the repository at this point in the history
  • Loading branch information
yungblud committed Dec 21, 2023
1 parent 9945637 commit 03b0ab2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
import com.brentvatne.common.api.TimedMetadata;
import com.brentvatne.common.api.Track;
import com.brentvatne.common.api.VideoTrack;
import com.brentvatne.common.react.VideoEventEmitter;
import com.brentvatne.common.toolbox.DebugLog;
import com.brentvatne.react.R;
import com.brentvatne.receiver.AudioBecomingNoisyReceiver;
Expand Down Expand Up @@ -1432,8 +1431,9 @@ public void onPlaybackParametersChanged(PlaybackParameters params) {

@Override
public void onVolumeChanged(float volume) {
eventEmitter.volumeChange(volume);
}
// todo
// eventEmitter.volumeChange(volume);
};

@Override
public void onIsPlayingChanged(boolean isPlaying) {
Expand Down Expand Up @@ -1491,30 +1491,30 @@ public int getTrackRendererIndex(int trackType) {

@Override
public void onMetadata(@NonNull Metadata metadata) {
ArrayList<TimedMetadata> metadataArray = new ArrayList<>();
for (int i = 0; i < metadata.length(); i++) {
Metadata.Entry entry = metadata.get(i);

if (entry instanceof Id3Frame) {
Id3Frame frame = (Id3Frame) metadata.get(i);

String value = "";

if (frame instanceof TextInformationFrame) {
TextInformationFrame txxxFrame = (TextInformationFrame) frame;
value = txxxFrame.value;
}
TimedMetadata timedMetadata = new TimedMetadata(frame.id, value);
metadataArray.add(timedMetadata);
} else if (entry instanceof EventMessage) {
EventMessage eventMessage = (EventMessage) entry;
TimedMetadata timedMetadata = new TimedMetadata(eventMessage.schemeIdUri, eventMessage.value);
metadataArray.add(timedMetadata);
} else {
DebugLog.d(TAG, "unhandled metadata " + entry.toString());
}
}
eventEmitter.timedMetadata(metadataArray);
// ArrayList<TimedMetadata> metadataArray = new ArrayList<>();
// for (int i = 0; i < metadata.length(); i++) {
// Metadata.Entry entry = metadata.get(i);
//
// if (entry instanceof Id3Frame) {
// Id3Frame frame = (Id3Frame) metadata.get(i);
//
// String value = "";
//
// if (frame instanceof TextInformationFrame) {
// TextInformationFrame txxxFrame = (TextInformationFrame) frame;
// value = txxxFrame.value;
// }
// TimedMetadata timedMetadata = new TimedMetadata(frame.id, value);
// metadataArray.add(timedMetadata);
// } else if (entry instanceof EventMessage) {
// EventMessage eventMessage = (EventMessage) entry;
// TimedMetadata timedMetadata = new TimedMetadata(eventMessage.schemeIdUri, eventMessage.value);
// metadataArray.add(timedMetadata);
// } else {
// DebugLog.d(TAG, "unhandled metadata " + entry.toString());
// }
// }
eventEmitter.timedMetadata(metadata);
}

// ReactExoplayerViewManager public api
Expand Down Expand Up @@ -2104,14 +2104,15 @@ public void setShutterColor(Integer color) {
@Override
public void onAdEvent(AdEvent adEvent) {
if (adEvent.getAdData() != null) {
eventEmitter.receiveAdEvent(adEvent.getType().name(), adEvent.getAdData());
eventEmitter.receiveAdEvent(adEvent.getType().name());
} else {
eventEmitter.receiveAdEvent(adEvent.getType().name());
}
}

@Override
public void onAdError(AdErrorEvent adErrorEvent) {
eventEmitter.receiveAdErrorEvent(adErrorEvent.getError());
// todo
// eventEmitter.receiveAdErrorEvent(adErrorEvent.getError());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void setDRM(final ReactExoplayerView videoView, @Nullable ReadableMap drm
if (drm != null && drm.hasKey(PROP_DRM_TYPE)) {
String drmType = ReactBridgeUtils.safeGetString(drm, PROP_DRM_TYPE);
String drmLicenseServer = ReactBridgeUtils.safeGetString(drm, PROP_DRM_LICENSESERVER);
ReadableMap drmHeaders = ReactBridgeUtils.safeGetMap(drm, PROP_DRM_HEADERS);
ReadableArray drmHeadersArray = (drm.hasKey(PROP_DRM_HEADERS)) ? drm.getArray(PROP_DRM_HEADERS) : null;
if (drmType != null && drmLicenseServer != null && Util.getDrmUuid(drmType) != null) {
UUID drmUUID = Util.getDrmUuid(drmType);
videoView.setDrmType(drmUUID);
Expand Down

0 comments on commit 03b0ab2

Please sign in to comment.