画中画窗口出现,但屏幕只是变黑并且没有播放音频。这是我在日志中唯一能找到的错误类型。它与此处的任何错误代码都不匹配,所以我不知道问题可能是什么。
W/YouTubeAndroidPlayerAPI: This YouTubePlayer has been paused - ignoring command.
我试着打电话给 youTubePlayerView.bringToFront(),没有做任何事情。我也尝试将播放器设置为全屏,但它似乎只是让 2 个重叠的窗口?
还有一些其他人遇到过这个问题,但据我所知没有人找到答案
相关代码(player.isPlaying 返回 false)
class VideoPage : YouTubeFailureRecoveryActivity(), YouTubePlayer.PlayerStateChangeListener {
private lateinit var player: YouTubePlayer
private lateinit var youtubePlayerView: YouTubePlayerView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.video_page)
youtubePlayerView = findViewById(R.id.youtube_player)
youtubePlayerView.initialize(apiKey, this)
@RequiresApi(Build.VERSION_CODES.O)
override fun onUserLeaveHint() {
try {
val rational = Rational(youtubePlayerView.width, youtubePlayerView.height)
val mParams = PictureInPictureParams.Builder()
.setAspectRatio(rational)
.build()
enterPictureInPictureMode(mParams)
} catch (e: IllegalStateException) {
e.printStackTrace()
}
}
@RequiresApi(Build.VERSION_CODES.O)
override fun onPause() {
super.onPause()
// If called while in PIP mode, do not pause playback
if (isInPictureInPictureMode) {
player.play()
}
}
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean,
newConfig: Configuration) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
if (isInPictureInPictureMode) {
btnPreferences.visibility = View.GONE
tvTitle.visibility = View.GONE
tvVideoInfo.visibility = View.GONE
player.setFullscreen(true)
player.play()
Log.e("help", player.isPlaying.toString())
} else {
// Restore the full-screen UI.
btnPreferences.visibility = View.VISIBLE
tvTitle.visibility = View.VISIBLE
tvVideoInfo.visibility = View.VISIBLE
player.play()
}
}
override fun onInitializationSuccess(
provider: YouTubePlayer.Provider?,
player: YouTubePlayer,
wasRestored: Boolean
) {
this.player = player
if (!wasRestored) {
player.loadVideo(sVideoCode)
player.setPlayerStateChangeListener(this)
}
}
override fun onLoaded(p0: String?) {
player.seekToMillis(intent.getIntExtra("timeStamp", 0))
player.play()
}
}
这是我清单中的活动:
<activity android:name=".VideoPage"
android:supportsPictureInPicture="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:configChanges=
"screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
我的日志猫:
2021-04-11 15:31:17.046 1734-1923/? V/InputDispatcher: Asynchronous input event injection succeeded.
2021-04-11 15:31:17.047 1734-1923/? V/InputDispatcher: Asynchronous input event injection succeeded.
2021-04-11 15:31:17.049 2271-2271/? V/StatusBar: mStatusBarWindow: com.android.systemui.statusbar.phone.StatusBarWindowView{a8e1f62 V.E...... ........ 0,0-1080,110} canPanelBeCollapsed(): false
2021-04-11 15:31:17.049 2271-2271/? V/StatusBar: mStatusBarWindow: com.android.systemui.statusbar.phone.StatusBarWindowView{a8e1f62 V.E...... ........ 0,0-1080,110} collapseBySetDisable: false
2021-04-11 15:31:17.050 1734-1769/? I/ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000100 cmp=com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher (has extras)} from uid 0
2021-04-11 15:31:17.055 1734-1769/? D/ActivityTaskManager: getPreferredLaunchDisplay usersetdisplayid 0 current displayId 0 paramspreferid 0
2021-04-11 15:31:17.056 1734-1769/? D/ActivityTaskManager: getPreferredLaunchDisplay usersetdisplayid 0 current displayId 0 paramspreferid 0
2021-04-11 15:31:17.058 1734-1769/? V/WindowManager: Changing focus from Window{95ed5a9 u0 com.example.youtubeplayerapp/com.example.youtubeplayerapp.VideoPage} to null displayId=0
2021-04-11 15:31:17.059 8320-8572/? D/MCLOG: [MC_TriggerHelper] PauseResumeTrigger
2021-04-11 15:31:17.063 8320-8320/? D/MCLOG: [MC_Service] onStartcommand()
2021-04-11 15:31:17.066 1734-7051/? W/WindowManager: Ignoring move of always-on-top stack=com.android.server.wm.DisplayContent$TaskStackContainers@745d9a6 to bottom
2021-04-11 15:31:17.082 26302-26549/? I/MediaCodec: (0x6eac1f0600) release
2021-04-11 15:31:17.083 8320-8572/? D/MCLOG: [MC_TriggerHelper] PauseResumeTrigger
2021-04-11 15:31:17.090 8320-8320/? D/MCLOG: [MC_Service] onStartcommand()
2021-04-11 15:31:17.102 1053-5608/? I/OMX-VDEC-1080P: omx_vdec::component_deinit() complete
2021-04-11 15:31:17.067 1734-7051/? I/chatty: uid=1000(system) Binder:1734_18 identical 1 line
2021-04-11 15:31:17.068 1734-7051/? W/WindowManager: Ignoring move of always-on-top stack=com.android.server.wm.DisplayContent$TaskStackContainers@745d9a6 to bottom
2021-04-11 15:31:17.102 1734-7051/? V/WindowManager: Changing focus from null to Window{e36508d u0 com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher} displayId=0
2021-04-11 15:31:17.106 1053-5608/? I/OMX-VDEC-1080P: Exit OMX vdec Destructor: fd=8
2021-04-11 15:31:17.106 1053-5608/? I/OMX-VDEC-1080P: Video slvp perflock released
2021-04-11 15:31:17.108 26302-30157/? D/SurfaceUtils: disconnecting from surface 0x6ede3d1010, reason disconnectFromSurface
2021-04-11 15:31:17.123 26302-26302/? W/YT.mlplayer: Stayawake OFF
2021-04-11 15:31:17.132 26302-26549/? I/MediaCodec: (0x6eac1ef800) flush
2021-04-11 15:31:17.134 26302-26549/? I/MediaCodec: (0x6eac1ef800) release
2021-04-11 15:31:17.138 26302-26302/? W/YouTubeAndroidPlayerAPI: This YouTubePlayer has been paused - ignoring command.
2021-04-11 15:31:17.142 1734-1772/? I/LaunchCheckinHandler: Displayed com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher,wp,wa,92
2021-04-11 15:31:17.142 1734-1772/? I/WindowManager: Window drawn AppWindowToken{43e1cf token=Token{81fc22e ActivityRecord{f7d7ca9 u0 com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher t13837}}}
2021-04-11 15:31:17.148 26302-26413/? W/YouTubeAndroidPlayerAPI: Pinging https://s.youtube.com/api/stats/qoe?cl=366526293&ei=HU1zYOimI5iuhwbx9bMQ&event=streamingstats&ns=yt&plid=AAW_t1txIwH31Wjn&cpn=EjFzwgbhSTP4GZZH&cplatform=mobile&cbr=com.google.android.youtube.api&c=android_embedded_player&cmodel=moto%20g(7)&cos=Android&csdk=29&cbrver=16.13.34&cver=16.13.34&cosver=10&cbrand=motorola&vis=67.550:2,352.648:0&vfs=353.780:137:137:135:a&conn=361.022:6&cplayer=ANDROID_EXOPLAYER_V2&bh=353.236:0.00,353.780:0.00,355.917:35.46,361.020:122.28&cmt=353.236:23.216,355.917:23.246,361.020:27.201&sur=353.287:1,353.293:3&bwe=353.780:564219.75&bat=361.033:0.780:1&vps=353.236:B,355.917:PL,361.020:SU&bwm=353.236:208323:0.395,355.917:1707847:1.651,361.020:2896121:2.246&ctmp=soc:qcom;msm8953,st:353.238;st,llv:126,pmqs:dt.35681192;lmq.720;dir.1&seq=6&docid=(scrubbed)
2021-04-11 15:31:17.166 1734-1772/? I/WindowManager: SURFACE show Surface(name=com.android.systemui.ImageWallpaper)/@0xcb05004 on display:0: com.android.systemui.ImageWallpaper
2021-04-11 15:31:17.171 1734-1772/? I/WindowManager: SURFACE show Surface(name=com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher)/@0x1adb574 on display:0: com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher
2021-04-11 15:31:17.176 3494-3494/? I/GoogleInputMethodService: GoogleInputMethodService.onFinishInput():3340
2021-04-11 15:31:17.177 3494-3494/? I/GoogleInputMethodService: GoogleInputMethodService.onStartInput():1929
2021-04-11 15:31:17.228 26180-19201/? D/AssistReceiver: call: lightWakeup | null | null
2021-04-11 15:31:17.233 746-2357/? I/netd: bandwidthAddNiceApp(10103) <2.54ms>
2021-04-11 15:31:17.274 840-1935/? D/MotSpeakerHelper: Speaker ON: volume 0.003668 (step 1), usecase MUSIC
2021-04-11 15:31:17.275 903-1357/? D/APM_AudioPolicyManager: stopOutput() output 21, stream 3, session 5329
2021-04-11 15:31:17.275 840-1935/? D/MotSpeakerHelper: Speaker ON: volume 0.500000 (step 12), usecase SAFE
2021-04-11 15:31:17.278 840-1935/? I/chatty: uid=1041(audioserver) audio@2.0-servi identical 1 line
2021-04-11 15:31:17.279 840-1935/? D/MotSpeakerHelper: Speaker ON: volume 0.500000 (step 12), usecase SAFE
2021-04-11 15:31:17.279 840-1972/? D/DlbDlbEffect: handle_EFFECT_CMD_DISABLE()
2021-04-11 15:31:17.279 840-1972/? D/DlbCrossfadeProcess: setEnabled transitioning from DAP_ACTIVE state to FADE_TO_BYPASS
2021-04-11 15:31:17.281 840-1972/? D/DlbDlbEffect: handle_EFFECT_CMD_SET_CONFIG()
2021-04-11 15:31:17.281 840-1972/? D/DlbDlbEffect: handle_EFFECT_CMD_SET_DEVICE(device=0x00000002)
2021-04-11 15:31:17.281 840-1972/? D/DlbDapEndpointParamCache: setDevice(device=0x00000002)
2021-04-11 15:31:17.281 866-866/? D/DMSService: setActiveDevice called with device = 0x2
2021-04-11 15:31:17.282 840-1972/? D/DlbEffectDap: setAudioMode(mode = 0)
2021-04-11 15:31:17.282 840-1972/? D/DlbDlbEffect: handle_EFFECT_CMD_ENABLE()
2021-04-11 15:31:17.282 840-1972/? D/DlbCrossfadeProcess: setEnabled transitioning from FADE_TO_BYPASS state to FADE_TO_ACTIVE
2021-04-11 15:31:17.351 837-1504/? D/NativeSensors: CapSensor: mPendingEvent.distance=0.000000
2021-04-11 15:31:17.353 2271-2271/? D/vol.VolumeDialogImpl: mDialog.dismiss()
2021-04-11 15:31:17.362 912-912/? E/qdgralloc: Unknown Color Space = 0
2021-04-11 15:31:17.532 27858-27858/com.example.youtubeplayerapp E/help: false
2021-04-11 15:31:17.534 26302-26302/? W/YouTubeAndroidPlayerAPI: This YouTubePlayer has been paused - ignoring command.
2021-04-11 15:31:17.535 1734-8288/? I/ActivityTaskManager: START u0 {cmp=com.android.systemui/.pip.phone.PipMenuActivity (has extras)} from uid 10064
2021-04-11 15:31:17.546 1734-8288/? D/ActivityTaskManager: getPreferredLaunchDisplay usersetdisplayid -1 current displayId -1 paramspreferid -1
2021-04-11 15:31:17.546 1734-8288/? W/ActivityTaskManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { flg=0x800000 cmp=com.android.systemui/.pip.phone.PipMenuActivity (has extras) }
2021-04-11 15:31:17.547 1734-8288/? D/ActivityTaskManager: getPreferredLaunchDisplay usersetdisplayid 0 current displayId 0 paramspreferid 0
2021-04-11 15:31:17.548 1734-8288/? W/WindowManager: Ignoring move of always-on-top stack=com.android.server.wm.DisplayContent$TaskStackContainers@745d9a6 to bottom
2021-04-11 15:31:17.553 8320-8572/? D/MCLOG: [MC_TriggerHelper] PauseResumeTrigger
2021-04-11 15:31:17.550 1734-8288/? W/WindowManager: Ignoring move of always-on-top stack=com.android.server.wm.DisplayContent$TaskStackContainers@745d9a6 to bottom
2021-04-11 15:31:17.554 1734-8288/? V/WindowManager: Changing focus from Window{e36508d u0 com.motorola.launcher3/com.android.launcher3.CustomizationPanelLauncher} to null displayId=0
2021-04-11 15:31:17.559 2271-2271/? W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@b2c2a19
2021-04-11 15:31:17.562 1734-2927/? I/WindowManager: SURFACE SIZE set 636x384 on display:0: com.example.youtubeplayerapp/com.example.youtubeplayerapp.VideoPage
2021-04-11 15:31:17.565 1734-2927/? I/WindowManager: Window drawn AppWindowToken{1b3c3df token=Token{b58a27e ActivityRecord{4a76c39 u0 com.example.youtubeplayerapp/.VideoPage t14075}}}
2021-04-11 15:31:17.566 8320-8320/? D/MCLOG: [MC_Service] onStartcommand()
2021-04-11 15:31:17.587 27858-27858/com.example.youtubeplayerapp W/RecyclerView: No adapter attached; skipping layout
2021-04-11 15:31:17.591 1734-1772/? I/WindowManager: Window drawn AppWindowToken{1b3c3df token=Token{b58a27e ActivityRecord{4a76c39 u0 com.example.youtubeplayerapp/.VideoPage t14075}}}
2021-04-11 15:31:17.599 1734-10094/? V/WindowManager: Changing focus from null to Window{35efcd1 u0 com.android.systemui/com.android.systemui.pip.phone.PipMenuActivity} displayId=0
2021-04-11 15:31:17.610 26302-26302/? W/YouTubeAndroidPlayerAPI: This YouTubePlayer has been paused - ignoring command.
2021-04-11 15:31:17.610 1734-1772/? I/LaunchCheckinHandler: Displayed com.android.systemui/.pip.phone.PipMenuActivity,wp,ca,59
2021-04-11 15:31:17.610 1734-1772/? I/WindowManager: Window drawn AppWindowToken{5078b5b token=Token{4212a6a ActivityRecord{216b055 u0 com.android.systemui/.pip.phone.PipMenuActivity t14076}}}
2021-04-11 15:31:17.611 1734-10094/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel
2021-04-11 15:31:17.616 1734-1772/? I/WindowManager: SURFACE show Surface(name=com.android.systemui/com.android.systemui.pip.phone.PipMenuActivity)/@0xb1f8336 on display:0: com.android.systemui/com.android.systemui.pip.phone.PipMenuActivity
2021-04-11 15:31:17.618 1734-1777/? I/ActivityTaskManager: Displayed com.android.systemui/.pip.phone.PipMenuActivity: +56ms
2021-04-11 15:31:17.623 3494-3494/? I/GoogleInputMethodService: GoogleInputMethodService.onFinishInput():3340
2021-04-11 15:31:17.624 3494-3494/? I/GoogleInputMethodService: GoogleInputMethodService.onStartInput():1929
2021-04-11 15:31:17.624 1734-2661/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel
2021-04-11 15:31:17.640 1734-8288/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel
2021-04-11 15:31:17.655 1734-10094/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel
2021-04-11 15:31:17.685 1734-1772/? I/WindowManager: SURFACE show Surface(name=com.example.youtubeplayerapp/com.example.youtubeplayerapp.VideoPage)/@0xa037509 on display:0: com.example.youtubeplayerapp/com.example.youtubeplayerapp.VideoPage
2021-04-11 15:31:17.672 1734-10094/? I/chatty: uid=1000(system) Binder:1734_1E identical 1 line
2021-04-11 15:31:17.689 1734-10094/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel
2021-04-11 15:31:17.705 1734-8341/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel
2021-04-11 15:31:17.721 1734-8341/? I/chatty: uid=1000(system) Binder:1734_1C identical 1 line
2021-04-11 15:31:17.738 1734-8341/? E/InputDispatcher: Window handle pip_input_consumer has no registered input channel