Search in sources :

Example 31 with PlayerView

use of com.google.android.exoplayer2.ui.PlayerView in project odysee-android by OdyseeTeam.

the class FileViewFragment method onExitPIPMode.

public void onExitPIPMode() {
    View root = getView();
    if (root != null) {
        PlayerView playerView = root.findViewById(R.id.file_view_exoplayer_view);
        playerView.setVisibility(View.VISIBLE);
    }
}
Also used : PlayerView(com.google.android.exoplayer2.ui.PlayerView) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView)

Example 32 with PlayerView

use of com.google.android.exoplayer2.ui.PlayerView in project odysee-android by OdyseeTeam.

the class MainActivity method setPlayerForMiniPlayerView.

private void setPlayerForMiniPlayerView() {
    PlayerView view = findViewById(R.id.global_now_playing_player_view);
    if (view != null) {
        view.setVisibility(View.VISIBLE);
        view.setPlayer(null);
        view.setPlayer(MainActivity.appPlayer);
    }
}
Also used : PlayerView(com.google.android.exoplayer2.ui.PlayerView)

Example 33 with PlayerView

use of com.google.android.exoplayer2.ui.PlayerView in project odysee-android by OdyseeTeam.

the class MainActivity method renderFullMode.

private void renderFullMode() {
    if (!inFullscreenMode) {
        showActionBar();
    } else {
        View v = findViewById(R.id.appbar);
        if (v != null) {
            v.setFitsSystemWindows(false);
        }
    }
    Fragment fragment = getCurrentFragment();
    boolean inMainView = currentDisplayFragment == null;
    boolean inFileView = fragment instanceof FileViewFragment;
    boolean inChannelView = fragment instanceof ChannelFragment;
    boolean inSearchView = fragment instanceof SearchFragment;
    findViewById(R.id.main_activity_other_fragment).setVisibility(!inMainView ? View.VISIBLE : View.GONE);
    findViewById(R.id.content_main).setVisibility(View.VISIBLE);
    findViewById(R.id.fragment_container_main_activity).setVisibility(inMainView ? View.VISIBLE : View.GONE);
    if (inMainView) {
        showBottomNavigation();
    }
    findViewById(R.id.appbar).setVisibility(inMainView || inSearchView ? View.VISIBLE : View.GONE);
    if (!inFileView && !inFullscreenMode && nowPlayingClaim != null) {
        findViewById(R.id.miniplayer).setVisibility(View.VISIBLE);
        setPlayerForMiniPlayerView();
    }
    View pipPlayerContainer = findViewById(R.id.pip_player_container);
    PlayerView pipPlayer = findViewById(R.id.pip_player);
    pipPlayer.setPlayer(null);
    pipPlayerContainer.setVisibility(View.GONE);
    playerReassigned = true;
}
Also used : FileViewFragment(com.odysee.app.ui.findcontent.FileViewFragment) PlayerView(com.google.android.exoplayer2.ui.PlayerView) SearchFragment(com.odysee.app.ui.findcontent.SearchFragment) PlayerView(com.google.android.exoplayer2.ui.PlayerView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ListView(android.widget.ListView) NavigationBarView(com.google.android.material.navigation.NavigationBarView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) FileViewFragment(com.odysee.app.ui.findcontent.FileViewFragment) DialogFragment(androidx.fragment.app.DialogFragment) SettingsFragment(com.odysee.app.ui.other.SettingsFragment) FollowingFragment(com.odysee.app.ui.findcontent.FollowingFragment) LibraryFragment(com.odysee.app.ui.library.LibraryFragment) ContentScopeDialogFragment(com.odysee.app.dialog.ContentScopeDialogFragment) SearchFragment(com.odysee.app.ui.findcontent.SearchFragment) Fragment(androidx.fragment.app.Fragment) PublishFragment(com.odysee.app.ui.publish.PublishFragment) InvitesFragment(com.odysee.app.ui.wallet.InvitesFragment) PlaylistFragment(com.odysee.app.ui.library.PlaylistFragment) RewardsFragment(com.odysee.app.ui.wallet.RewardsFragment) WalletFragment(com.odysee.app.ui.wallet.WalletFragment) BaseFragment(com.odysee.app.ui.BaseFragment) AddToListsDialogFragment(com.odysee.app.dialog.AddToListsDialogFragment) AllContentFragment(com.odysee.app.ui.findcontent.AllContentFragment) PublishesFragment(com.odysee.app.ui.publish.PublishesFragment)

Example 34 with PlayerView

use of com.google.android.exoplayer2.ui.PlayerView in project odysee-android by OdyseeTeam.

the class FileViewFragment method playMedia.

private void playMedia() {
    boolean newPlayerCreated = false;
    Context context = getContext();
    if (MainActivity.appPlayer == null && context != null) {
        AudioAttributes audioAttributes = new AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).setContentType(C.CONTENT_TYPE_MOVIE).build();
        MainActivity.appPlayer = new ExoPlayer.Builder(context).build();
        MainActivity.appPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
        MainActivity.appPlayer.setAudioAttributes(audioAttributes, true);
        MainActivity.playerCache = new SimpleCache(context.getCacheDir(), new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 256), new ExoDatabaseProvider(context));
        if (context instanceof MainActivity) {
            MainActivity activity = (MainActivity) context;
            activity.initMediaSession();
            activity.initPlaybackNotification();
        }
        newPlayerCreated = true;
    }
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        activity.initPlaybackNotification();
    }
    Claim claimToPlay = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    View root = getView();
    if (root != null) {
        PlayerView view = root.findViewById(R.id.file_view_exoplayer_view);
        view.setShutterBackgroundColor(Color.TRANSPARENT);
        view.setPlayer(MainActivity.appPlayer);
        view.getPlayer().addListener(new Player.Listener() {

            @Override
            public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
                isPlaying = playWhenReady;
                Player.Listener.super.onPlayWhenReadyChanged(playWhenReady, reason);
            }
        });
        view.setUseController(true);
        if (context instanceof MainActivity) {
            ((MainActivity) context).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
        if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claimToPlay.getClaimId()) && !newPlayerCreated) {
            // if the claim is already playing, we don't need to reload the media source
            if (MainActivity.appPlayer != null) {
                MainActivity.appPlayer.setPlayWhenReady(true);
                playbackStarted = true;
                if (context instanceof MainActivity) {
                    MainActivity activity = (MainActivity) context;
                    activity.displayCurrentlyPlayingVideo();
                }
                // reconnect the app player
                if (fileViewPlayerListener != null) {
                    MainActivity.appPlayer.addListener(fileViewPlayerListener);
                }
                setPlayerForPlayerView();
                loadAndScheduleDurations();
            }
            return;
        }
        if (MainActivity.appPlayer != null) {
            showBuffering();
            if (fileViewPlayerListener != null) {
                MainActivity.appPlayer.addListener(fileViewPlayerListener);
            }
            if (context instanceof MainActivity) {
                ((MainActivity) context).setNowPlayingClaim(claimToPlay, currentUrl);
            }
            MainActivity.appPlayer.setPlayWhenReady(Objects.requireNonNull((MainActivity) (getActivity())).isMediaAutoplayEnabled());
            if (claimToPlay.hasSource()) {
                getStreamingUrlAndInitializePlayer(claimToPlay);
            } else {
                String mediaSourceUrl = getLivestreamUrl();
                DefaultHttpDataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();
                if (context != null) {
                    dataSourceFactory.setUserAgent(Util.getUserAgent(context, getString(R.string.app_name)));
                }
                MediaSource mediaSource = null;
                if (mediaSourceUrl != null) {
                    if (!mediaSourceUrl.equals("notlive")) {
                        Map<String, String> defaultRequestProperties = new HashMap<>(1);
                        defaultRequestProperties.put("Referer", "https://bitwave.tv");
                        dataSourceFactory.setDefaultRequestProperties(defaultRequestProperties);
                        mediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mediaSourceUrl));
                    } else {
                        if (claimToPlay.getThumbnailUrl() != null && context != null) {
                            ImageView thumbnailView = root.findViewById(R.id.file_view_livestream_thumbnail);
                            Glide.with(context.getApplicationContext()).asBitmap().load(claimToPlay.getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(thumbnailView);
                        }
                        root.findViewById(R.id.file_view_livestream_not_live).setVisibility(View.VISIBLE);
                        TextView userNotStreaming = root.findViewById(R.id.user_not_streaming);
                        userNotStreaming.setText(getString(R.string.user_not_live_yet, claimToPlay.getPublisherName()));
                        userNotStreaming.setVisibility(View.VISIBLE);
                    }
                }
                if (mediaSource != null) {
                    MainActivity.appPlayer.setMediaSource(mediaSource, true);
                    MainActivity.appPlayer.prepare();
                }
            }
        }
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LeastRecentlyUsedCacheEvictor(com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor) ExoDatabaseProvider(com.google.android.exoplayer2.database.ExoDatabaseProvider) AttributeProviderFactory(org.commonmark.renderer.html.AttributeProviderFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) MainActivity(com.odysee.app.MainActivity) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Player(com.google.android.exoplayer2.Player) AudioAttributes(com.google.android.exoplayer2.audio.AudioAttributes) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) MediaSource(com.google.android.exoplayer2.source.MediaSource) ProgressiveMediaSource(com.google.android.exoplayer2.source.ProgressiveMediaSource) HlsMediaSource(com.google.android.exoplayer2.source.hls.HlsMediaSource) PlayerView(com.google.android.exoplayer2.ui.PlayerView) DefaultHttpDataSource(com.google.android.exoplayer2.upstream.DefaultHttpDataSource) Claim(com.odysee.app.model.Claim)

Example 35 with PlayerView

use of com.google.android.exoplayer2.ui.PlayerView in project odysee-android by OdyseeTeam.

the class FileViewFragment method onEnterPIPMode.

public void onEnterPIPMode() {
    View root = getView();
    if (root != null) {
        PlayerView playerView = root.findViewById(R.id.file_view_exoplayer_view);
        playerView.setVisibility(View.GONE);
    }
}
Also used : PlayerView(com.google.android.exoplayer2.ui.PlayerView) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView)

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