player: prevent audio player trigger and tips leak on SAF video playback
When opening a video file via the Android Storage Access Framework (SAF), FileUtils.getUri() resolves the content:// URI into an fd://<fd> file descriptor URI. Because the path lacks a dot extension, MediaWrapper.defineType() fails to identify the format and leaves MediaWrapper.mType as -1 (TYPE_ALL / Unknown). During playback initialization, PlaylistManager.playIndex() initiates background playback to probe the unknown stream. Upon receiving MediaPlayer.Event.Playing (with newMedia = true): 1. No SurfaceView is attached yet, causing player.isVideoPlaying() to return false. 2. PlaylistManager evaluated: `if (player.hasRenderer || !player.isVideoPlaying()) showAudioPlayer.value = true` 3. AudioPlayerContainerActivity observed this LiveData event, invoked showAudioPlayer(), and set `showAudioPlayerWhenResumed = true`. 4. Shortly after (~20ms), LibVLC's demuxer detected video tracks (MediaPlayer.Event.ESAdded), triggering switchToVideo(). 5. While switchToVideo() launched VideoPlayerActivity and called hideAudioPlayer(), `showAudioPlayerWhenResumed` was never reset to false. Consequently, when the user finishes watching the video and returns to MainActivity, onResume() evaluates `showAudioPlayerWhenResumed == true` and calls showAudioPlayerImpl() -> initAudioPlayer(). On a fresh install where PREF_AUDIOPLAYER_TIPS_SHOWN is false, this inflates audio_player_tips.xml, erroneously displaying the Audio Tutorial overlay on top of the Home screen. Fix this by ensuring PlaylistManager only sets showAudioPlayer to true if the media is explicitly forced to audio (MEDIA_FORCE_AUDIO) or has no detectable video tracks (!player.canSwitchToVideo()). This preserves standard audio files, context-menu "Play as audio", and in-player audio mode transitions while preventing false triggers during video stream probing.
R
Riteshwar Poddar committed
4e773d5546c331a57aa67d3cb8103f701f944228
Parent: be798e8
Committed by Nicolas Pomepuy <nicolas@videolabs.io>
on 9/3/2026, 11:21:24 AM