use of org.thoughtcrime.securesms.mms.VideoSlide in project Signal-Android by WhisperSystems.
the class VideoEditorFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
player = view.findViewById(R.id.video_player);
uri = requireArguments().getParcelable(KEY_URI);
isVideoGif = requireArguments().getBoolean(KEY_IS_VIDEO_GIF);
long maxOutput = requireArguments().getLong(KEY_MAX_OUTPUT);
long maxSend = requireArguments().getLong(KEY_MAX_SEND);
VideoSlide slide = new VideoSlide(requireContext(), uri, 0, isVideoGif);
boolean autoplay = isVideoGif;
player.setWindow(requireActivity().getWindow());
player.setVideoSource(slide, autoplay);
if (slide.isVideoGif()) {
player.setPlayerCallback(new VideoPlayer.PlayerCallback() {
@Override
public void onPlaying() {
controller.onPlayerReady();
}
@Override
public void onStopped() {
// Do nothing.
}
@Override
public void onError() {
controller.onPlayerError();
}
});
player.hideControls();
player.loopForever();
} else if (MediaConstraints.isVideoTranscodeAvailable()) {
hud = view.findViewById(R.id.video_editor_hud);
hud.setEventListener(this);
updateHud(data);
if (data.durationEdited) {
player.clip(data.startTimeUs, data.endTimeUs, autoplay);
}
try {
hud.setVideoSource(slide, new VideoBitRateCalculator(maxOutput), maxSend);
hud.setVisibility(View.VISIBLE);
startPositionUpdates();
} catch (IOException e) {
Log.w(TAG, e);
}
player.setOnClickListener(v -> {
player.pause();
hud.showPlayButton();
});
player.setPlayerCallback(new VideoPlayer.PlayerCallback() {
@Override
public void onReady() {
controller.onPlayerReady();
}
@Override
public void onPlaying() {
hud.fadePlayButton();
}
@Override
public void onStopped() {
hud.showPlayButton();
}
@Override
public void onError() {
controller.onPlayerError();
}
});
}
}
Aggregations