Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media session is not destroyed when exiting activity #4

Open
holywyvern opened this issue Sep 23, 2017 · 1 comment
Open

Media session is not destroyed when exiting activity #4

holywyvern opened this issue Sep 23, 2017 · 1 comment

Comments

@holywyvern
Copy link

I'm having a probem when using this library.
When I exit the activity, I'm calling the following:

fragment.closePlayer(); // does nothing

This one always return null for the view.

YoutubeTvView view = (YoutubeTvView) findViewById(fr.bmartel.youtubetv.R.id.youtubetv_view);
        if (view != null) {
            view.stopVideo();
            view.closePlayer();
        }

This is the activity I'm using:

public class YoutubePlaybackActivity extends Activity {

    private static final String TAG = YoutubePlaybackActivity.class.getSimpleName();

    public static final String EXTRA_VIDEO_ID = "videoId";
    public static final String EXTRA_CONTENT_LIST = "ContentList";

    private YouTubePlayerView mYouTubePlayerView;

    private static final String API_KEY = "AIzaSyBgDhyTYKAIfDlHODy-r6BopuhTTNp7nro";
    private YoutubeTvFragment mFragment;

    public void toggleHideyBar() {

        // The UI options currently enabled are represented by a bitfield.
        // getSystemUiVisibility() gives us that bitfield.
        int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
        int newUiOptions = uiOptions;
        boolean isImmersiveModeEnabled =
                ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
        if (isImmersiveModeEnabled) {
            Log.i(TAG, "Turning immersive mode mode off. ");
        } else {
            Log.i(TAG, "Turning immersive mode mode on.");
        }

        newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
        newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_youtube_playback);
        toggleHideyBar();
        Bundle args = new Bundle();
        args.putString("videoId",      getIntent().getStringExtra(EXTRA_VIDEO_ID));
        args.putString("videoQuality", "hd1080");
        mFragment = YoutubeTvFragment.newInstance(args);

        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.add(R.id.root, mFragment);
        transaction.commit();
    }

    @Override
    protected void onDestroy() {
        if (mFragment != null) {
            mFragment.closePlayer();
        }
        YoutubeTvView view = (YoutubeTvView) findViewById(fr.bmartel.youtubetv.R.id.youtubetv_view);
        if (view != null) {
            view.stopVideo();
            view.closePlayer();
        }
        super.onDestroy();
    }
}

is there something I'm forgetting about?

Thanks

@geovannyAndrew
Copy link

I have the same problem. Have you found any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants