Search in sources :

Example 26 with PlayerView

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());
    });
}
Also used : ViewGroup(android.view.ViewGroup) VideoAdUnit(org.prebid.mobile.VideoAdUnit) AdSize(org.prebid.mobile.AdSize) PlayerView(com.google.android.exoplayer2.ui.PlayerView) ImaAdsLoader(com.google.android.exoplayer2.ext.ima.ImaAdsLoader) HashSet(java.util.HashSet)

Example 27 with PlayerView

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;
}
Also used : ImageView(android.widget.ImageView) PlayerControlView(com.google.android.exoplayer2.ui.PlayerControlView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) View(android.view.View) TextView(android.widget.TextView) TrackSelectionView(com.google.android.exoplayer2.ui.TrackSelectionView) Nullable(androidx.annotation.Nullable)

Example 28 with PlayerView

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();
}
Also used : TransformationException(com.google.android.exoplayer2.transformer.TransformationException) Transformer(com.google.android.exoplayer2.transformer.Transformer) TransformationRequest(com.google.android.exoplayer2.transformer.TransformationRequest) Matrix(android.graphics.Matrix) MediaItem(com.google.android.exoplayer2.MediaItem) Nullable(androidx.annotation.Nullable) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 29 with PlayerView

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);
}
Also used : DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) ImaServerSideAdInsertionMediaSource(com.google.android.exoplayer2.ext.ima.ImaServerSideAdInsertionMediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) RenderersFactory(com.google.android.exoplayer2.RenderersFactory) ImaAdsLoader(com.google.android.exoplayer2.ext.ima.ImaAdsLoader) AdsLoader(com.google.android.exoplayer2.source.ads.AdsLoader)

Example 30 with PlayerView

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();
}
Also used : ExoPlayerUtil(in.testpress.course.util.ExoPlayerUtil) FrameLayout(android.widget.FrameLayout) PlayerView(com.google.android.exoplayer2.ui.PlayerView) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout)

Aggregations

PlayerView (com.google.android.exoplayer2.ui.PlayerView)25 TextView (android.widget.TextView)20 View (android.view.View)15 ImageView (android.widget.ImageView)14 RecyclerView (androidx.recyclerview.widget.RecyclerView)13 WebView (android.webkit.WebView)12 Uri (android.net.Uri)10 AdapterView (android.widget.AdapterView)10 NestedScrollView (androidx.core.widget.NestedScrollView)10 PhotoView (com.github.chrisbanes.photoview.PhotoView)10 SolidIconView (com.odysee.app.ui.controls.SolidIconView)10 MediaItem (com.google.android.exoplayer2.MediaItem)8 Context (android.content.Context)7 Nullable (androidx.annotation.Nullable)7 Player (com.google.android.exoplayer2.Player)7 MediaSource (com.google.android.exoplayer2.source.MediaSource)7 ProgressiveMediaSource (com.google.android.exoplayer2.source.ProgressiveMediaSource)7 SuppressLint (android.annotation.SuppressLint)6 Intent (android.content.Intent)6 SimpleExoPlayer (com.google.android.exoplayer2.SimpleExoPlayer)6