File tree Expand file tree Collapse file tree
android/src/main/kotlin/wtf/flutter/vr_player Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class VideoPlayerController(
117117 result.success(player?.isPlaying == true )
118118 }
119119 " dispose" -> {
120- dispose()
120+ dispose(false )
121121 result.success(true )
122122 }
123123 " onSizeChanged" -> {
@@ -135,13 +135,13 @@ class VideoPlayerController(
135135 }
136136 " fullScreen" -> {
137137 if (mediaEntry?.isVRMediaType == true ) {
138- dispose()
138+ dispose(true )
139139 }
140140 result.success(true )
141141 }
142142 " onPause" -> {
143143 if (mediaEntry?.isVRMediaType == true ) {
144- dispose()
144+ dispose(false )
145145 } else {
146146 player?.onApplicationPaused()
147147 }
@@ -157,7 +157,7 @@ class VideoPlayerController(
157157 }
158158 " onOrientationChanged" -> {
159159 if (mediaEntry?.isVRMediaType == true ) {
160- dispose()
160+ dispose(true )
161161 }
162162 result.success(true )
163163 }
@@ -330,12 +330,15 @@ class VideoPlayerController(
330330 return vrSettings
331331 }
332332
333- fun dispose () {
333+ fun dispose (isRebuilding : Boolean = false ) {
334334 player?.let {
335335 this .videoPlayerState = VideoPlayerState (it.currentPosition, it.isPlaying)
336- it.destroy()
336+
337+ if (! isRebuilding) {
338+ it.destroy()
339+ player = null
340+ }
337341 }
338- player = null
339342
340343 playerEventStateChanged = null
341344 playerEventDurationChanged = null
You can’t perform that action at this time.
0 commit comments