YouTubePlayer: going fullscreen from portrait phone orientation can easily get out of fullscreen
up vote
1
down vote
favorite
If you hold the phone in portrait orientation and you click fullscreen button (of YouTubePlayerView
) it easily can get you back (turns off fullscreen) if you shake the phone a little bit
Official YouTube app works normally: you press fullscreen button while holding the phone in portrait orientation and if you shake it a little bit it still stays in fullscreen landscape mode. And if you rotate your phone to landscape orientation and back again to portrait orientation only then it turns off fullscreen (as it should be)
So I would like to implement the same behavior from official YouTube app
I tried to set different Fullscreen flags for YouTubePlayer
but it doesn't affect anything
activity manifest
<activity
android:label="@string/playerview_demo_name"
android:name=".PlayerViewDemoActivity"
android:screenOrientation="user"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
activity java
public class PlayerViewDemoActivity extends YouTubeFailureRecoveryActivity {
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.playerview);
YouTubePlayerView youTubeView = findViewById(R.id.youtube_view);
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this);
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored)
if (!wasRestored)
player.cueVideo("wKJ9KzGQq0w");
/*
FULLSCREEN_FLAG_CONTROL_ORIENTATION;
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI;
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
FULLSCREEN_FLAG_CUSTOM_LAYOUT;
*/
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
@Override
protected YouTubePlayer.Provider getYouTubePlayerProvider()
return (YouTubePlayerView) findViewById(R.id.youtube_view);
Mb YouTube app does something like this:
after pressing fullscreen button they set (only if programmatic phone display's orientation was in portrait mode)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
then they use device sensors to detect approximate orientation (if you hold the phone in portrait/landscape orientation) - Detect Android device orientation (NOT screen orientation)
when you rotate the phone with your hands to landscape orientation they set
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
android android-youtube-api
add a comment |
up vote
1
down vote
favorite
If you hold the phone in portrait orientation and you click fullscreen button (of YouTubePlayerView
) it easily can get you back (turns off fullscreen) if you shake the phone a little bit
Official YouTube app works normally: you press fullscreen button while holding the phone in portrait orientation and if you shake it a little bit it still stays in fullscreen landscape mode. And if you rotate your phone to landscape orientation and back again to portrait orientation only then it turns off fullscreen (as it should be)
So I would like to implement the same behavior from official YouTube app
I tried to set different Fullscreen flags for YouTubePlayer
but it doesn't affect anything
activity manifest
<activity
android:label="@string/playerview_demo_name"
android:name=".PlayerViewDemoActivity"
android:screenOrientation="user"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
activity java
public class PlayerViewDemoActivity extends YouTubeFailureRecoveryActivity {
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.playerview);
YouTubePlayerView youTubeView = findViewById(R.id.youtube_view);
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this);
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored)
if (!wasRestored)
player.cueVideo("wKJ9KzGQq0w");
/*
FULLSCREEN_FLAG_CONTROL_ORIENTATION;
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI;
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
FULLSCREEN_FLAG_CUSTOM_LAYOUT;
*/
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
@Override
protected YouTubePlayer.Provider getYouTubePlayerProvider()
return (YouTubePlayerView) findViewById(R.id.youtube_view);
Mb YouTube app does something like this:
after pressing fullscreen button they set (only if programmatic phone display's orientation was in portrait mode)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
then they use device sensors to detect approximate orientation (if you hold the phone in portrait/landscape orientation) - Detect Android device orientation (NOT screen orientation)
when you rotate the phone with your hands to landscape orientation they set
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
android android-youtube-api
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
If you hold the phone in portrait orientation and you click fullscreen button (of YouTubePlayerView
) it easily can get you back (turns off fullscreen) if you shake the phone a little bit
Official YouTube app works normally: you press fullscreen button while holding the phone in portrait orientation and if you shake it a little bit it still stays in fullscreen landscape mode. And if you rotate your phone to landscape orientation and back again to portrait orientation only then it turns off fullscreen (as it should be)
So I would like to implement the same behavior from official YouTube app
I tried to set different Fullscreen flags for YouTubePlayer
but it doesn't affect anything
activity manifest
<activity
android:label="@string/playerview_demo_name"
android:name=".PlayerViewDemoActivity"
android:screenOrientation="user"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
activity java
public class PlayerViewDemoActivity extends YouTubeFailureRecoveryActivity {
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.playerview);
YouTubePlayerView youTubeView = findViewById(R.id.youtube_view);
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this);
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored)
if (!wasRestored)
player.cueVideo("wKJ9KzGQq0w");
/*
FULLSCREEN_FLAG_CONTROL_ORIENTATION;
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI;
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
FULLSCREEN_FLAG_CUSTOM_LAYOUT;
*/
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
@Override
protected YouTubePlayer.Provider getYouTubePlayerProvider()
return (YouTubePlayerView) findViewById(R.id.youtube_view);
Mb YouTube app does something like this:
after pressing fullscreen button they set (only if programmatic phone display's orientation was in portrait mode)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
then they use device sensors to detect approximate orientation (if you hold the phone in portrait/landscape orientation) - Detect Android device orientation (NOT screen orientation)
when you rotate the phone with your hands to landscape orientation they set
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
android android-youtube-api
If you hold the phone in portrait orientation and you click fullscreen button (of YouTubePlayerView
) it easily can get you back (turns off fullscreen) if you shake the phone a little bit
Official YouTube app works normally: you press fullscreen button while holding the phone in portrait orientation and if you shake it a little bit it still stays in fullscreen landscape mode. And if you rotate your phone to landscape orientation and back again to portrait orientation only then it turns off fullscreen (as it should be)
So I would like to implement the same behavior from official YouTube app
I tried to set different Fullscreen flags for YouTubePlayer
but it doesn't affect anything
activity manifest
<activity
android:label="@string/playerview_demo_name"
android:name=".PlayerViewDemoActivity"
android:screenOrientation="user"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
activity java
public class PlayerViewDemoActivity extends YouTubeFailureRecoveryActivity {
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.playerview);
YouTubePlayerView youTubeView = findViewById(R.id.youtube_view);
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this);
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored)
if (!wasRestored)
player.cueVideo("wKJ9KzGQq0w");
/*
FULLSCREEN_FLAG_CONTROL_ORIENTATION;
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI;
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
FULLSCREEN_FLAG_CUSTOM_LAYOUT;
*/
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
@Override
protected YouTubePlayer.Provider getYouTubePlayerProvider()
return (YouTubePlayerView) findViewById(R.id.youtube_view);
Mb YouTube app does something like this:
after pressing fullscreen button they set (only if programmatic phone display's orientation was in portrait mode)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
then they use device sensors to detect approximate orientation (if you hold the phone in portrait/landscape orientation) - Detect Android device orientation (NOT screen orientation)
when you rotate the phone with your hands to landscape orientation they set
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
android android-youtube-api
android android-youtube-api
edited Nov 10 at 20:38
asked Nov 10 at 20:08
user924
490221
490221
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242972%2fyoutubeplayer-going-fullscreen-from-portrait-phone-orientation-can-easily-get-o%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown