use of com.google.android.exoplayer2.ui.PlayerView in project prebid-mobile-android by prebid.
the class GamVideoInstream method create.
public static void create(ViewGroup wrapper, String adUnitId, String configId) {
playerView = new PlayerView(wrapper.getContext());
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600);
wrapper.addView(playerView, params);
VideoAdUnit.Parameters parameters = new VideoAdUnit.Parameters();
parameters.setMimes(Collections.singletonList("video/mp4"));
parameters.setProtocols(Collections.singletonList(Signals.Protocols.VAST_2_0));
parameters.setPlaybackMethod(Collections.singletonList(Signals.PlaybackMethod.AutoPlaySoundOff));
parameters.setPlacement(Signals.Placement.InStream);
adUnit = new VideoAdUnit(configId, 640, 480);
adUnit.setParameters(parameters);
adUnit.fetchDemand((resultCode, keysMap) -> {
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(640, 480));
adsUri = Uri.parse(Util.generateInstreamUriForGam(adUnitId, sizes, keysMap));
ImaAdsLoader.Builder imaBuilder = new ImaAdsLoader.Builder(wrapper.getContext());
adsLoader = imaBuilder.build();
initializePlayer(wrapper.getContext());
});
}
use of com.google.android.exoplayer2.ui.PlayerView in project zype-android by zype.
the class PlayerFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_player, container, false);
playerView = rootView.findViewById(R.id.player_view);
imageThumbnail = rootView.findViewById(R.id.imageThumbnail);
buttonFullscreen = playerView.findViewById(R.id.exo_fullscreen);
buttonFullscreen.setOnClickListener(view -> {
boolean fullscreen = UiUtils.isLandscapeOrientation(getActivity());
if (fullscreen) {
setPortraitOrientation();
} else {
setLandscapeOrientation();
}
});
buttonNext = playerView.findViewById(R.id.buttonNext);
buttonNext.setOnClickListener(v -> {
onNext();
});
buttonPrevious = playerView.findViewById(R.id.buttonPrevious);
buttonPrevious.setOnClickListener(v -> {
onPrevious();
});
buttonSubtitles = playerView.findViewById(R.id.buttonSubtitles);
buttonSubtitles.setOnClickListener(v -> {
onSubtitles();
});
textPosition = playerView.findViewById(R.id.exo_position);
textPositionLive = playerView.findViewById(R.id.textPositionLive);
textDuration = playerView.findViewById(R.id.exo_duration);
textDurationLive = playerView.findViewById(R.id.textDurationLive);
viewTimeBar = playerView.findViewById(R.id.exo_progress);
castView = rootView.findViewById(R.id.layoutCast);
castControlView = rootView.findViewById(R.id.cast_control_view);
return rootView;
}
use of com.google.android.exoplayer2.ui.PlayerView in project ExoPlayer by google.
the class TransformerActivity method createTransformer.
@RequiresNonNull({ "playerView", "debugTextView", "informationTextView", "transformationStopwatch", "progressViewGroup", "debugFrame" })
private Transformer createTransformer(@Nullable Bundle bundle, String filePath) {
Transformer.Builder transformerBuilder = new Transformer.Builder(/* context= */
this);
if (bundle != null) {
TransformationRequest.Builder requestBuilder = new TransformationRequest.Builder();
requestBuilder.setFlattenForSlowMotion(bundle.getBoolean(ConfigurationActivity.SHOULD_FLATTEN_FOR_SLOW_MOTION));
@Nullable String audioMimeType = bundle.getString(ConfigurationActivity.AUDIO_MIME_TYPE);
if (audioMimeType != null) {
requestBuilder.setAudioMimeType(audioMimeType);
}
@Nullable String videoMimeType = bundle.getString(ConfigurationActivity.VIDEO_MIME_TYPE);
if (videoMimeType != null) {
requestBuilder.setVideoMimeType(videoMimeType);
}
int resolutionHeight = bundle.getInt(ConfigurationActivity.RESOLUTION_HEIGHT, /* defaultValue= */
C.LENGTH_UNSET);
if (resolutionHeight != C.LENGTH_UNSET) {
requestBuilder.setResolution(resolutionHeight);
}
Matrix transformationMatrix = getTransformationMatrix(bundle);
if (!transformationMatrix.isIdentity()) {
requestBuilder.setTransformationMatrix(transformationMatrix);
}
requestBuilder.experimental_setEnableHdrEditing(bundle.getBoolean(ConfigurationActivity.ENABLE_HDR_EDITING));
transformerBuilder.setTransformationRequest(requestBuilder.build()).setRemoveAudio(bundle.getBoolean(ConfigurationActivity.SHOULD_REMOVE_AUDIO)).setRemoveVideo(bundle.getBoolean(ConfigurationActivity.SHOULD_REMOVE_VIDEO));
}
return transformerBuilder.addListener(new Transformer.Listener() {
@Override
public void onTransformationCompleted(MediaItem mediaItem) {
TransformerActivity.this.onTransformationCompleted(filePath);
}
@Override
public void onTransformationError(MediaItem mediaItem, TransformationException exception) {
TransformerActivity.this.onTransformationError(exception);
}
}).setDebugViewProvider(new DemoDebugViewProvider()).build();
}
use of com.google.android.exoplayer2.ui.PlayerView in project ExoPlayer by google.
the class PlayerActivity method createMediaSourceFactory.
private MediaSource.Factory createMediaSourceFactory() {
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder serverSideAdLoaderBuilder = new ImaServerSideAdInsertionMediaSource.AdsLoader.Builder(/* context= */
this, playerView);
if (serverSideAdsLoaderState != null) {
serverSideAdLoaderBuilder.setAdsLoaderState(serverSideAdsLoaderState);
}
serverSideAdsLoader = serverSideAdLoaderBuilder.build();
ImaServerSideAdInsertionMediaSource.Factory imaServerSideAdInsertionMediaSourceFactory = new ImaServerSideAdInsertionMediaSource.Factory(serverSideAdsLoader, new DefaultMediaSourceFactory(dataSourceFactory));
return new DefaultMediaSourceFactory(dataSourceFactory).setAdsLoaderProvider(this::getClientSideAdsLoader).setAdViewProvider(playerView).setServerSideAdInsertionMediaSourceFactory(imaServerSideAdInsertionMediaSourceFactory);
}
use of com.google.android.exoplayer2.ui.PlayerView in project android-sdk by testpress.
the class ExoPlayerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testpress_exo_player_view);
PlayerView playerView = findViewById(R.id.exo_player_view);
int matchParent = ConstraintLayout.LayoutParams.MATCH_PARENT;
playerView.setLayoutParams(new ConstraintLayout.LayoutParams(matchParent, matchParent));
findViewById(R.id.exo_fullscreen_button).setVisibility(View.GONE);
String url = getIntent().getStringExtra(VIDEO_URL);
float startPosition = getIntent().getFloatExtra(START_POSITION, 0);
float speedRate = getIntent().getFloatExtra(SPEED_RATE, 1);
FrameLayout exoPlayerMainFrame = findViewById(R.id.exo_player_main_frame);
exoPlayerUtil = new ExoPlayerUtil(this, exoPlayerMainFrame, url, startPosition, true, speedRate);
exoPlayerUtil.openOnlyInFullScreen();
}
Aggregations