Samsung tv bild in bild

Starting an 8.0 (API level 26), allows activities zu launch inpicture-in-picture (PiP) mode. PiP ist a one-of-a-kind type des multi-window setting mostlyused zum video playback. It lasst uns the user watch a video in a klein window pinnedto a corner des the display while navigating betwee apps or browsing content onthe taste screen.

Du schaust: Samsung tv bild in bild

Alas, your browser doesn"t support HTML5 video. That"s OK! sie can blieb download die video und watch it through a video player.

PiP leverages the multi-window APIs make available bei 7.0 to provide thepinned videos overlay window. Kommen sie add PiP zu your app, you need to register youractivities that assistance PiP, switch her activity to PiP setting as needed, andmake certain UI facets are hidden and video playback continues when die activityis in PiP mode.

The PiP home window appears in the topmost layer von the screen, in a corner chosenby die system.

How users tun können interact with ns PiP window

Users kann sein drag ns PiP window zu another location. Starting in 12, userscan also:

Single-tap ns window to display a full-screen toggle, a nearby button, asettings button, and custom plot provided von your app (for example, playcontrols).

Double-tap ns window to toggle betwee the current PiP size and maximum PiPsize. Stash the window von dragging the to die left or right edge; to unstashthe window, one of two people tap ns visible part of the stashed window or traction it out.

Resize die PiP home window using pinch-to-zoom.

Your app controls when ns current activity enters PiP mode. Below are someexamples:

An activity kann enter PiP mode when ns user taps die home taste (in buttonnavigation mode) or swipes up kommen sie home (in gesture navigation mode. (This ishow google Maps continues zu display direction while die user runs anotheractivity at ns same time.)

Your app can move a videos into PiP mode when ns user navigates rückseitig from thevideo kommen sie browse various other content.

Your anwendung can move a video into PiP setting while a user the town hall the end of anepisode von content. The main screen display screens promotional or summaryinformation about die next episode bei the series.

Your apps can administer a way zum users to queue trost additional content while theywatch a video. Ns video continues playing in PiP setting while the hauptsächlich screendisplays a inhalt selection activity.

Declare picture-in-picture support

By default, the system does notfall automatically support PiP zum apps.If you want support PiP an your app, register your videoactivity an your manifest von zu true. Also, specifythat your task handles layout construction changes dafür that your activitydoesn't relaunch wie man layout transforms occur throughout PiP setting transitions.

Switch her activity to picture-in-picture

To get in picture-in-picture mode, in activity need to callenterPictureInPictureMode().For example, ns followingcode switches an activity kommen sie PiP setting when ns user clicks a dedicated button inthe app's UI:


override fun onActionClicked(action: Action) if ( == activity?.enterPictureInPictureMode() return


Overridepublic void onActionClicked(Action action) if (action.getId() == getActivity().enterPictureInPictureMode(); return; ...
You might want to include logic the switches in activty into PiP mode insteadof going into die background. For example, google Maps switches zu PiP mode ifthe user presses die home or recents taste while the apps is navigating. Sie cancatch this case über overridingonUserLeaveHint():


override funny onUserLeaveHint() if (iWantToBeInPipModeNow()) enterPictureInPictureMode()


Overridepublic void onUserLeaveHint () if (iWantToBeInPipModeNow()) enterPictureInPictureMode();

Make transitions zu PiP mode smoother native gesture navigation

Starting in 12, you tun können use thesetAutoEnterEnabledflag zu provide smoother transitions zu PiP mode when swiping up kommen sie home ingesture navigation mode.

To carry out this feature:

Call setPictureInPictureParams with ns up-to-datePictureInPictureParams early. The apps should notfall wait zum theonUserLeaveHint call back (as that would schutz done in 11).

For example, bei app may want zu call setPictureInPictureParams on die veryfirst playback und any adhering to playback if die aspect ratio is changed.

Call setAutoEnterEnabled(false) as needed. Zum example, it’s most likely notoptimal zum a video anwendung to get in PiP if die current playback is in pausedstate.

Handle UI throughout picture-in-picture

When the activity enters or exits picture-in-picture mode, the system callsActivity.onPictureInPictureModeChanged()or Fragment.onPictureInPictureModeChanged().

You should override these callbacks to redraw ns activity's UI elements. Keepin mind that an PiP setting your activity ist shown bei a small window. Users cannotinteract through your app's UI elements wie it's an PiP mode und the einzelheiten ofsmall UI elements may be difficult kommen sie see. Videobilien playback tasks withminimal UI provide ns best user experience.

Mehr sehen: Samsung Galaxy Tab A7 Test, Samsung Galaxy Tab A7 Review: A Fantastic Value

If your app needs kommen sie provide tradition actions zum PiP, see Addcontrols in this document. Remove various other UI aspects before youractivity start PiP and restore them when your activity becomes fullscreenagain:


override funny onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) if (isInPictureInPictureMode) // Hide die full-screen UI (controls, etc.) while bei picture-in-picture mode. else // Restore die full-screen UI.


Overridepublic void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, construction newConfig) if (isInPictureInPictureMode) // Hide ns full-screen UI (controls, etc.) while in picture-in-picture mode. else // Restore die full-screen UI. ...

Support smoother animations wie exiting out of PiP mode

Starting in 12, die SourceRectHintflag is now reused zu implement smoother animation wie man exiting out von PiP mode.On exit, the system creates die animation using ns current availablesourceRectHint, whether it’s the original Rect used kommen sie enter PiP or anupdated Rect provided von the app.

To implement this feature, update your apps as follows:

Add controls

The PiP window kann sein display controls when the user opens ns window's menu (bytapping die window ~ above a mobile device, or selecting ns menu from ns TVremote.)

If an app has bei active mediasession,then play, pause, next, and previous controls wollen appear.

You can so specify practice actions explicitly von buildingPictureInPictureParamswith )">PictureInPictureParams.Builder.setActions()before beginning PiP mode, und pass die params wie man you enter PiP mode usingenterPictureInPictureMode( setPictureInPictureParams( careful. If freundin try kommen sie add an ext thangetMaxNumPictureInPictureActions(),you'll just get die maximum number.

Disable smooth resizing weil das non-video content 12 adds the setSeamlessResizeEnabledflag, which provides a viel smoother cross-fading animation wie man resizingnon-video content bei the PiP window. Previously, resizing non-video content bei aPiP window could produce jarring visual artifacts.

The setSeamlessResizeEnabled flag zu sein set to true über default forbackward-compatibility. Leaving this set zu true zum video content, und changeit zu false for non-video content.

To disable smooth resizing zum non-video content:

setPictureInPictureParams(new PictureInPictureParams.Builder() .setSeamlessResizeEnabled(false) .build());

Continuing video playback while in picture-in-picture

When your activity switches kommen sie PiP, the system places die activity in thepaused state and calls the activity'sonPause() method. Videoplayback should notfall be paused und should continue playing if die activity ispaused while an PiP mode.

In 7.0 und later, freundin should pause and resume videos playback wie man thesystem calls your activity'sonStop() andonStart(). Von doing this,you can avoid having zu check if your anwendung is in PiP mode an onPause() andexplicitly continuing playback.

If you have to halt playback bei your onPause() implementation, check zum PiPmode by calling isInPictureInPictureMode() und handle playback appropriately,for example:


override funny onPause() super.onPause() // If called while in PiP mode, carry out not pause playback if (isInPictureInPictureMode) // proceed playback else // usage existing playback logic zum paused task behavior.


Overridepublic void onPause() // If called while bei PiP mode, do not pause playback if (isInPictureInPictureMode()) // continue playback ... rather // usage existing playback logic zum paused activity behavior. ...
When your task switches out of PiP mode rückseitig to full-screen mode, thesystem resumes her activity and calls youronResume() method.

Using a single playback activity weil das picture-in-picture

In your app, a user might choose a neu video when browsing for inhalt onthe main screen, while a videobilien playback task is in PiP mode. Play die newvideo bei the currently playback activity an full display mode, instead oflaunching a new activity that might confuse ns user.

To certain a einzel activity is used zum video playback requests andswitched into or out of PiP mode as needed, set the activity' zu singleTask in your manifest:

In your activity, overrideonNewIntent()and handhaben the new video, stopping any kind of existing video playback if needed.

Best practices

PiP could be disabled on devices that oase low RAM. Prior to your app uses PiP,check to be certain it is available von callinghasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE).

PiP ist intended zum activities that play full-screen video. When switching youractivity into PiP mode, protect against showing noþeles except video content. Track whenyour task enters PiP mode und hide UI elements, as defined inHandling UI throughout picture-in-picture.

When in activity is an PiP mode, von default the doesn't acquire input focus. Toreceive input events while an PiP mode, useMediaSession.setCallback().For more info on utilizing setCallback() seeDisplaying a jetzt Playing Card

When your app is an PiP mode, videobilien playback in the PiP window tun können cause audiointerference with another app, such as a music player anwendung or voice find app.To stop this, inquiry audio focus wie man you start playing die video, and handleaudio focus change notifications, as described in ManagingAudio Focus. If freundin receivenotification von audio emphasis loss when bei PiP mode, pause or stop videos playback.

When your anwendung is about zu enter PiP, note only the top activity möchte enterPicture-in-Picture. In some situations such together on multi-window devices, it ispossible ns activity listed below will jetzt be shown and become clearly shows again alongsidethe PiP activity. You should handhaben this situation accordingly, including theactivity below getting in onResume() or bei onPause() callback. It ist alsopossible that the user may interact with die activity. Zum example, if you havea videos list task displayed und the playing videobilien activity in PiP mode, theuser might choose a new video from the list and the PiP task should updateaccordingly.

Additional sample code

To download a sample app written in, lakers Picture-in-PictureSample.To download a sample app written in Kotlin, see PictureInPictureSample (Kotlin).

Mehr sehen: The Rolling Stones Erstes Konzert In Deutschland, Randale Bei Rolling

Content and code samples top top this buchseite are topic to die licenses described an the content License. Java zu sein a registered trademark von Oracle and/or the affiliates.

< "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing die information i need" , "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complex / auch many steps" , "type": "thumb-down", "id": "outOfDate", "label":"Out des date" , "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" , "type": "thumb-down", "id": "otherDown", "label":"Other" > < "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy zu understand" , "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved mine problem" , "type": "thumb-up", "id": "otherUp", "label":"Other" >


Discover Devices


Documentation und Downloads


Language English Bahasa Indonesia Español – América Latina Português – Brasil 中文 – 简体 日本語 한국어