Unable to resume playback in exoplayer when app minimized and resumed

0

In my simple exoPlayer i play video file and when app is minimized and maximized i was not able to resume the play back here is my code.

private void initializePlayer() {
        if (player == null) {
            DefaultTrackSelector trackSelector = new DefaultTrackSelector(this);
            RenderersFactory renderersFactory = new DefaultRenderersFactory(this).setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
            player = new SimpleExoPlayer.Builder(this, renderersFactory).setTrackSelector(trackSelector).build();
            playerView.setPlayer(player);
            mediaSession = new MediaSessionCompat(this, getString(R.string.app_name));
            MediaSessionConnector mediaSessionConnector = new MediaSessionConnector(mediaSession);
            mediaSessionConnector.setPlayer(player);
            playerView.setControllerShowTimeoutMs(CONTROLLER_TIMEOUT);
            // playerView.setResizeMode(mPrefs.resizeMode);

            player.setMediaItems(mediaItems);
            
            play = true;
            mediaSession.setActive(true);
            player.addListener(playbackStateListener);
            player.prepare();
            startPosition = UtilsFunction.convertStringToInt(playListArray.get(playListId).getLastPlayedAtTime());
            player.seekTo(playListId, 0);
            if (startPosition <= 0) {
                player.setPlayWhenReady(true);
            } else {
                player.setPlayWhenReady(false);
            }
            Log.d(TAG, "initializePlayer: player set to false");
        }

below is the log right from the app is minimized, and resuming playback.

Log

2021-02-11 22:14:52.463 1832-2245/? I/ash: above launcher front pkgs: [com.example.jlplayer, com.google.android.youtube, com.huawei.android.launcher]
2021-02-11 22:14:52.484 1014-1307/? D/ActivityManager: allPausedActivitiesComplete: r=ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399} state=PAUSING
2021-02-11 22:14:52.489 1832-1977/? I/ScenarioService: ID_VIDEO_END : EventID=135 Pkg=com.example.jlplayer Pid=15230
2021-02-11 22:14:52.493 1014-8181/? W/HwActivityManagerServiceEx: appSwitch from: com.example.jlplayer to: com.huawei.android.launcher
2021-02-11 22:14:52.493 1014-8181/? V/WindowManager: findFocusedWindow: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}} below Reached focused app=AppWindowToken{601b134 token=Token{f614c07 ActivityRecord{1b41246 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1416}}}
2021-02-11 22:14:52.502 1832-1977/? I/AppsUsage: scnOff:false FgAPP:com.huawei.android.launcher BgAPP:com.example.jlplayer
2021-02-11 22:14:52.508 1014-2819/? V/WindowManager: findFocusedWindow: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}} below Reached focused app=AppWindowToken{601b134 token=Token{f614c07 ActivityRecord{1b41246 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1416}}}
2021-02-11 22:14:52.754 2904-7229/? D/[HwRecSys]HwRecSysService: onEvent actionID: 10016 msg:com.example.jlplayer       
2021-02-11 22:14:52.756 1832-2262/? I/PGServer: report state:10016 event type:1 pid:0 uid:0 pkg:com.example.jlplayer to pid: 1014
2021-02-11 22:14:52.758 1014-1862/? V/WindowManager: findFocusedWindow: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}} below Reached focused app=AppWindowToken{601b134 token=Token{f614c07 ActivityRecord{1b41246 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1416}}}
2021-02-11 22:14:52.759 1832-2262/? I/PGServer: report state:10009 event type:2 pid:0 uid:0 pkg:com.example.jlplayer to pid: 1014
2021-02-11 22:14:52.759 1832-2262/? I/PGServer: report state:10009 event type:2 pid:0 uid:0 pkg:com.example.jlplayer to pid: 1832
2021-02-11 22:14:52.759 1832-2262/? I/SceneReceiver: state type: 10009 eventType:2 pid:0 uid:0 pkg:com.example.jlplayer
2021-02-11 22:14:53.154 15230-16005/com.example.jlplayer D/SurfaceUtils: connecting to surface 0x7f1d090010, reason connectToSurface
2021-02-11 22:14:53.154 15230-16005/com.example.jlplayer I/MediaCodec: [OMX.IMG.MSVDX.Decoder.AVC] setting surface generation to 15595523
2021-02-11 22:14:53.155 15230-16005/com.example.jlplayer D/SurfaceUtils: disconnecting from surface 0x7f1d090010, reason connectToSurface(reconnect)
2021-02-11 22:14:53.155 15230-16005/com.example.jlplayer D/SurfaceUtils: connecting to surface 0x7f1d090010, reason connectToSurface(reconnect)
2021-02-11 22:14:53.156 15230-16006/com.example.jlplayer D/SurfaceUtils: disconnecting from surface 0x7f1d090010, reason setNativeWindowSizeFormatAndUsage
2021-02-11 22:14:53.156 15230-16006/com.example.jlplayer D/SurfaceUtils: connecting to surface 0x7f1d090010, reason setNativeWindowSizeFormatAndUsage
2021-02-11 22:14:53.156 15230-16006/com.example.jlplayer D/SurfaceUtils: set up nativeWindow 0x7f1d090010 for 720x480, color 0x300, rotation 0, usage 0x20002900
2021-02-11 22:14:53.157 15230-16005/com.example.jlplayer D/SurfaceUtils: disconnecting from surface 0x7eefde9010, reason disconnectFromSurface
2021-02-11 22:14:53.187 15230-15230/com.example.jlplayer D/TAG: releasePlayer: 274224
2021-02-11 22:14:53.189 15230-15230/com.example.jlplayer I/ExoPlayerImpl: Release daf1770 [ExoPlayerLib/2.13.0] [HWPRA-H, PRA-AL00X, HUAWEI, 26] [goog.exo.core, goog.exo.ui, goog.exo.mediasession]
2021-02-11 22:14:53.200 15230-15989/com.example.jlplayer D/android.media.AudioTrack: [HSM] AudioTrace pause() uid: 10468, pid: 15230
2021-02-11 22:14:53.203 15230-16057/com.example.jlplayer D/android.media.AudioTrack: [HSM] AudioTrace stop() uid: 10468, pid: 15230
2021-02-11 22:14:53.205 15230-16006/com.example.jlplayer W/ACodec: forcing OMX state to Idle when received shutdown in ExecutingState
2021-02-11 22:14:53.244 15230-16005/com.example.jlplayer D/SurfaceUtils: disconnecting from surface 0x7f1d090010, reason disconnectFromSurface
2021-02-11 22:14:53.253 15230-16012/com.example.jlplayer W/ACodec: forcing OMX state to Idle when received shutdown in ExecutingState
2021-02-11 22:14:53.281 15230-15314/com.example.jlplayer W/libEGL: EGLNativeWindowType 0x7ef6f9e010 disconnect failed
2021-02-11 22:14:53.299 1014-1862/? V/WindowManager: notifyAppStopped: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}
2021-02-11 22:14:53.300 1014-1862/? E/WindowManager: win=Window{defadc0 u0 com.example.jlplayer/Activity.PlayerActivity} destroySurfaces: appStopped=true win.mWindowRemovalAllowed=false win.mRemoveOnExit=false
2021-02-11 22:14:53.300 1014-1862/? I/WindowManager: Destroying surface Surface(name=com.example.jlplayer/Activity.PlayerActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2089 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:899 com.android.server.wm.HwWindowStateAnimator.destroySurfaceLocked:1006 com.android.server.wm.WindowState.destroyOrSaveSurfaceUnchecked:2998 com.android.server.wm.WindowState.destroySurface:2951 com.android.server.wm.AppWindowToken.destroySurfaces:671 com.android.server.wm.AppWindowToken.destroySurfaces:655 com.android.server.wm.AppWindowToken.notifyAppStopped:699 
2021-02-11 22:14:53.311 1014-1862/? D/HwLocationManagerService: on transact ADD_LOCATION_MODE  uid is 10468 , expectedmode is 3 , packagename is com.example.jlplayer
2021-02-11 22:14:53.313 1014-1862/? D/HwLocationManagerService: addSupervisoryControlProc, mExpectedMode is network,packagename=com.example.jlplayer, mSupervisoryPkgList is {com.google.android.youtube=network, com.example.jlplayer=network}
2021-02-11 22:14:57.569 1590-1762/? D/ReporterUtil:  e id:338 type:{status:false,pkg:com.example.jlplayer}
2021-02-11 22:14:57.590 1014-6010/? V/WindowManager: No longer Stopped: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}
2021-02-11 22:14:57.590 1014-6010/? W/HwActivityManagerServiceEx: appSwitch from: com.android.systemui to: com.example.jlplayer
2021-02-11 22:14:57.591 1014-6010/? V/WindowManager: findFocusedWindow: AppWindowToken{139a5cb token=Token{d1a689a ActivityRecord{9324945 u0 com.android.systemui/.recents.RecentsActivity t845}}} below Reached focused app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}
2021-02-11 22:14:57.597 1832-1977/? D/ScenarioService: front pkg : com.example.jlplayer launcher: false
2021-02-11 22:14:57.597 1832-1977/? D/ScenarioService: new above launcher front pkgs: [com.example.jlplayer]
2021-02-11 22:14:57.597 1832-1977/? I/AppsUsage: scnOff:false FgAPP:com.example.jlplayer BgAPP:com.android.systemui
2021-02-11 22:14:57.601 1014-6162/? D/HwLocationManagerService: on transact ADD_LOCATION_MODE  uid is 10468 , expectedmode is 3 , packagename is com.example.jlplayer
2021-02-11 22:14:57.602 1014-6162/? D/HwLocationManagerService: addSupervisoryControlProc, mExpectedMode is network,packagename=com.example.jlplayer, mSupervisoryPkgList is {com.google.android.youtube=network, com.example.jlplayer=network}
2021-02-11 22:14:57.608 1014-1370/? D/EmcomManagerService: forePackage name is com.example.jlplayer
2021-02-11 22:14:57.614 2904-7229/? D/[HwRecSys]HwRecSysService: onEvent actionID: 10009 msg:com.example.jlplayer       
2021-02-11 22:14:57.615 1832-2245/? I/ash: front pkg : com.example.jlplayer launcher: false
2021-02-11 22:14:57.615 1832-2245/? I/ash: above launcher front pkgs: [com.example.jlplayer]
2021-02-11 22:14:57.615 1014-6010/? V/WindowManager: notifyAppResumed: wasStopped=true AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}
2021-02-11 22:14:57.621 1014-6010/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:57.625 1832-2262/? I/PGServer: report state:10009 event type:1 pid:0 uid:0 pkg:com.example.jlplayer to pid: 1014
2021-02-11 22:14:57.625 1832-2262/? I/PGServer: report state:10009 event type:1 pid:0 uid:0 pkg:com.example.jlplayer to pid: 1832
2021-02-11 22:14:57.625 1832-2262/? I/SceneReceiver: state type: 10009 eventType:1 pid:0 uid:0 pkg:com.example.jlplayer
2021-02-11 22:14:57.626 1832-2661/? D/HwThermalStateManager: current foreapp pkg : com.example.jlplayer
2021-02-11 22:14:57.638 1832-3662/? W/libc: Set property "debug.aps.process.name" to "com.example.jlplayer"
2021-02-11 22:14:57.649 15230-15230/com.example.jlplayer I/ExoPlayerImpl: Init cad576d [ExoPlayerLib/2.13.0] [HWPRA-H, PRA-AL00X, HUAWEI, 26]
2021-02-11 22:14:57.657 1014-1272/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:57.666 15230-15230/com.example.jlplayer W/MediaSessionCompat: Couldn't find a unique registered media button receiver in the given context.
2021-02-11 22:14:57.668 1014-1509/? D/MediaSessionService: Media button session is changed to com.example.jlplayer/JL Player (userId=0)
2021-02-11 22:14:57.697 1014-1467/? I/ActivityManager: START u0 {cmp=com.example.jlplayer/com.google.android.gms.ads.AdActivity (has extras)} from uid 10468
2021-02-11 22:14:57.700 1014-1467/? V/WindowManager: addAppToken: AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}} controller={TaskWindowContainerController taskId=2399} at 2147483647
2021-02-11 22:14:57.710 15230-15230/com.example.jlplayer D/Debug: handleDiscontinuity:  Seek within current playlist item.
2021-02-11 22:14:57.716 15230-15230/com.example.jlplayer D/Debug: initializePlayer: player set to false
2021-02-11 22:14:57.757 15230-15230/com.example.jlplayer I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
2021-02-11 22:14:57.909 1014-1467/? W/WindowManager: EGLdebug Created surface WindowStateAnimator{d2fda3e com.example.jlplayer/Activity.PlayerActivity}
2021-02-11 22:14:57.910 1014-1467/? V/HwPhoneWindowManager: updateSystemUiColorLw window=Window{defadc0 u0 com.example.jlplayer/Activity.PlayerActivity},EmuiStyle=0,StatusBarColor=0xffffffff,NavigationBarColor=0xff000000, mLastIsEmuiLightStyle=-1, mForceNotchStatusBar=false
2021-02-11 22:14:57.919 15230-15314/com.example.jlplayer D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
2021-02-11 22:14:57.929 15230-15230/com.example.jlplayer E/BpSurfaceComposerClient: Failed to transact (-1)
2021-02-11 22:14:57.929 15230-15230/com.example.jlplayer E/BpSurfaceComposerClient: Failed to transact (-1)
2021-02-11 22:14:57.972 1014-1467/? D/WindowManager: finishDrawingWindow: Window{defadc0 u0 com.example.jlplayer/Activity.PlayerActivity} mDrawState=DRAW_PENDING
2021-02-11 22:14:57.985 1014-1467/? V/WindowManager: No longer Stopped: AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}
2021-02-11 22:14:57.987 1014-1467/? V/WindowManager: No longer Stopped: AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}
2021-02-11 22:14:57.991 1014-1467/? V/WindowManager: findFocusedWindow: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}} below Reached focused app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}
2021-02-11 22:14:57.998 1014-1467/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:57.998 1014-1467/? V/WindowManager: Check opening app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.006 15230-15230/com.example.jlplayer W/InputMethodManager: startInputReason = 1
2021-02-11 22:14:58.007 15230-15230/com.example.jlplayer W/InputMethodManager: startInputOrWindowGainedFocus failed. Window focus may have already been lost. win=android.view.ViewRootImpl$W@2eb836a view=DecorView@e4d705b[PlayerActivity],focus=false,windowFocus=true,window=android.view.ViewRootImpl$W@2eb836a,temporaryDetach=false
2021-02-11 22:14:58.014 15230-15230/com.example.jlplayer D/HwCust: Create obj success use class android.app.HwCustActivityImpl
2021-02-11 22:14:58.015 15230-15230/com.example.jlplayer D/HwCust: Create obj success use class android.app.HwCustHwWallpaperManagerImpl
2021-02-11 22:14:58.017 15230-15230/com.example.jlplayer V/ActivityThread: ActivityThread,callActivityOnCreate
2021-02-11 22:14:58.036 15230-15230/com.example.jlplayer D/HwFLClassLoader: USE_FEATURE_LIST had not init! 
2021-02-11 22:14:58.046 15230-15230/com.example.jlplayer D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdOverlayCreatorImpl
2021-02-11 22:14:58.068 15230-15230/com.example.jlplayer D/HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x0103000f, context : com.google.android.gms.ads.AdActivity@eb66c36, Nhwext : 0, get Blur : disable with , null
2021-02-11 22:14:58.069 15230-15230/com.example.jlplayer D/HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x0103000f, context : com.google.android.gms.ads.AdActivity@eb66c36, Nhwext : 0, get Blur : disable with , null
2021-02-11 22:14:58.112 15230-15230/com.example.jlplayer D/ActivityThread: add activity client record, r= ActivityRecord{dbea4b1 token=android.os.BinderProxy@96c0f8 {com.example.jlplayer/com.google.android.gms.ads.AdActivity}} token= android.os.BinderProxy@96c0f8
2021-02-11 22:14:58.125 15230-15314/com.example.jlplayer D/OpenGLRenderer:   HWUI Binary is  enabled
2021-02-11 22:14:58.130 1014-1509/? V/WindowManager: Adding Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity} to AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}
2021-02-11 22:14:58.131 1014-1509/? V/WindowManager: addWindow: New client android.os.BinderProxy@5691a80: window=Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity} Callers=com.android.server.wm.HwWindowManagerService.addWindow:585 com.android.server.wm.Session.addToDisplay:199 android.view.IWindowSession$Stub.onTransact:124 com.android.server.wm.Session.onTransact:161 android.os.Binder.execTransact:675 
2021-02-11 22:14:58.143 1014-1272/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.143 1014-1272/? V/WindowManager: Check opening app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.145 1014-1509/? D/WindowManager: finishDrawingWindow: Window{defadc0 u0 com.example.jlplayer/Activity.PlayerActivity} mDrawState=READY_TO_SHOW
2021-02-11 22:14:58.146 15230-15230/com.example.jlplayer I/PressGestureDetector: onAttached begin
2021-02-11 22:14:58.146 15230-15230/com.example.jlplayer I/PressGestureDetector: onAttached end
2021-02-11 22:14:58.147 15230-16072/com.example.jlplayer I/PressGestureDetector: HiTouch restricted: AboardArea.
2021-02-11 22:14:58.193 1014-1509/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.193 1014-1509/? V/WindowManager: Check opening app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.199 1014-1509/? W/WindowManager: EGLdebug Created surface WindowStateAnimator{3d4a5d6 com.example.jlplayer/com.google.android.gms.ads.AdActivity}
2021-02-11 22:14:58.201 1014-1509/? V/HwPhoneWindowManager: updateSystemUiColorLw window=Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity},EmuiStyle=0,StatusBarColor=0xff000000,NavigationBarColor=0xff000000, mLastIsEmuiLightStyle=-1, mForceNotchStatusBar=false
2021-02-11 22:14:58.209 1014-1509/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.209 1014-1509/? V/WindowManager: Check opening app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.222 1014-1091/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.222 1014-1091/? V/WindowManager: Check opening app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}: allDrawn=false startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.233 15230-15314/com.example.jlplayer D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
2021-02-11 22:14:58.337 1014-1091/? D/WindowManager: finishDrawingWindow: Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity} mDrawState=DRAW_PENDING
2021-02-11 22:14:58.343 1014-1272/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.343 1014-1272/? V/WindowManager: Check opening app=AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:14:58.391 1014-1177/? I/ActivityManager: Displayed com.example.jlplayer/com.google.android.gms.ads.AdActivity: +375ms
2021-02-11 22:14:58.474 15230-15314/com.example.jlplayer D/OpenGLRenderer:   HWUI Binary is  enabled
2021-02-11 22:14:58.501 15230-15230/com.example.jlplayer W/InputMethodManager: startInputReason = 1
2021-02-11 22:14:58.810 1014-6162/? D/WindowManager: finishDrawingWindow: Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity} mDrawState=HAS_DRAWN
2021-02-11 22:15:00.669 15230-15230/com.example.jlplayer I/HwSecImmHelper: mSecurityInputMethodService is null
2021-02-11 22:15:00.679 15230-15230/com.example.jlplayer I/HwSecImmHelper: mSecurityInputMethodService is null
2021-02-11 22:15:00.698 15230-15230/com.example.jlplayer I/Ads: Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("24F1CA620420EB6A729C6BBAF788CAA1") to get test ads on this device.
2021-02-11 22:15:00.725 15230-16067/com.example.jlplayer V/AudioManager: getRingerMode...
2021-02-11 22:15:00.743 1014-1862/? W/ActivityManager: Duplicate finish request for ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399 f}
2021-02-11 22:15:00.762 1014-1862/? D/ActivityManager: allPausedActivitiesComplete: r=ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399 f} state=FINISHING
2021-02-11 22:15:00.763 1014-1862/? V/WindowManager: No longer Stopped: AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}
2021-02-11 22:15:00.764 1014-1862/? V/HwPhoneWindowManager: updateSystemUiColorLw window=Window{defadc0 u0 com.example.jlplayer/Activity.PlayerActivity},EmuiStyle=0,StatusBarColor=0xffffffff,NavigationBarColor=0xff000000, mLastIsEmuiLightStyle=-1, mForceNotchStatusBar=false
2021-02-11 22:15:00.772 1014-1862/? V/WindowManager: notifyAppResumed: wasStopped=false AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}
2021-02-11 22:15:00.780 1014-1862/? V/WindowManager: Check opening app=AppWindowToken{4234d89 token=Token{c930090 ActivityRecord{c0b0f53 u0 com.example.jlplayer/Activity.PlayerActivity t2399}}}: allDrawn=true startingDisplayed=false startingMoved=false isRelaunching()=false
2021-02-11 22:15:00.824 15230-15230/com.example.jlplayer W/Ads: #004 The webview is destroyed. Ignoring action.
2021-02-11 22:15:00.828 15230-15230/com.example.jlplayer W/Ads: #004 The webview is destroyed. Ignoring action.
2021-02-11 22:15:00.828 15230-15230/com.example.jlplayer W/Ads: #004 The webview is destroyed. Ignoring action.
2021-02-11 22:15:00.829 15230-15230/com.example.jlplayer W/Ads: #004 The webview is destroyed. Ignoring action.
2021-02-11 22:15:00.860 15230-15230/com.example.jlplayer W/Ads: #004 The webview is destroyed. Ignoring action.
2021-02-11 22:15:00.867 15230-15230/com.example.jlplayer W/InputMethodManager: startInputReason = 1
2021-02-11 22:15:00.920 15230-15314/com.example.jlplayer W/libEGL: EGLNativeWindowType 0x7efd610010 disconnect failed
2021-02-11 22:15:01.052 15230-15230/com.example.jlplayer D/ActivityThread: Remove activity client record, r= ActivityRecord{dbea4b1 token=android.os.BinderProxy@96c0f8 {com.example.jlplayer/com.google.android.gms.ads.AdActivity}} token= android.os.BinderProxy@96c0f8
2021-02-11 22:15:01.054 1014-1467/? V/WindowManager: removeIfPossible: Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity} callers=com.android.server.wm.WindowState.removeIfPossible:1914 com.android.server.wm.WindowManagerService.removeWindow:2040 com.android.server.wm.Session.remove:218 android.view.IWindowSession$Stub.onTransact:242 com.android.server.wm.Session.onTransact:161 
2021-02-11 22:15:01.055 1014-1467/? I/WindowManager: Destroying surface Surface(name=com.example.jlplayer/com.google.android.gms.ads.AdActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2089 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:899 com.android.server.wm.HwWindowStateAnimator.destroySurfaceLocked:1006 com.android.server.wm.WindowState.removeImmediately:1899 com.android.server.wm.WindowState.removeIfPossible:2051 com.android.server.wm.WindowState.removeIfPossible:1914 com.android.server.wm.WindowManagerService.removeWindow:2040 com.android.server.wm.Session.remove:218 
2021-02-11 22:15:01.056 1014-1467/? V/WindowManager: postWindowRemoveCleanupLocked: Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity}
2021-02-11 22:15:01.056 1014-1467/? V/WindowManager: Removing Window{2d378b9 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity} from AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}}
2021-02-11 22:15:01.065 1014-3169/? V/WindowManager: removeAppToken: AppWindowToken{cb58fb2 token=Token{ea3bdbd ActivityRecord{5d30114 u0 com.example.jlplayer/com.google.android.gms.ads.AdActivity t2399}}} delayed=false Callers=com.android.server.wm.DisplayContent.removeAppToken:994 com.android.server.wm.AppWindowContainerController.removeContainer:352 com.android.server.am.ActivityRecord.removeWindowContainer:1045 com.android.server.am.ActivityStack.removeActivityFromHistoryLocked:4486 
2021-02-11 22:15:02.371 15230-15230/com.example.jlplayer I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:204204100
2021-02-11 22:15:02.371 15230-15230/com.example.jlplayer I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 204204100

Help me why i was not able to resume playback.

Or what am i doing wrong, correct me if am wrong. also i have added resume, pause and play.

@Override
public void onResume() {
    super.onResume();
    if (Util.SDK_INT <= 23 || player == null) {
        initializePlayer();
        if (playerView != null) {
            playerView.onResume();
        }
    }
}

My exoplayer version in 2.13.0

java
android
exoplayer2.x
asked on Stack Overflow Feb 11, 2021 by sanoj lawrence

1 Answer

0

Try moving outside the scope of the initialization check the call to playerView.onResume, otherwise if already initialized, then when resuming the activity again in APIs > 23 it will never reach it, because player will not be null.

@Override
public void onResume() {
    super.onResume();

    if (Util.SDK_INT <= 23 || player == null) {
        initializePlayer();
    }

    if (playerView != null) {
        playerView.onResume();
    }
}
answered on Stack Overflow Feb 12, 2021 by PerracoLabs

User contributions licensed under CC BY-SA 3.0