Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): check for valid width and height on video format data #4394

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mmttt89
Copy link
Contributor

@mmttt89 mmttt89 commented Jan 27, 2025

Summary

Check for a valid width or height on video format's track data

Motivation

Fix unwanted behavior for video urls with no valid width and height (width=-1 or height=-1).

fix : #4282

Check this if needed: related comment

Changes

ExoPlayerView.kt file:
Add an if to check the width and height of the format data

      if (format.width > 0 || format.height > 0) { 
              layout.updateAspectRatio(format)  // Proceed only if width/height are valid
      }

@freeboub freeboub merged commit ad52668 into TheWidlarzGroup:master Jan 27, 2025
3 checks passed
@Nardeep
Copy link

Nardeep commented Jan 29, 2025

https://d1wis83g01tmlr.cloudfront.net/file/videos/file-1737557775527/playlist.m3u8

here this is link , when you are playing in view then it will crop out right Side check in video there is shadow on right side of video but react-native-video crops it.

Screenshot 2025-01-29 at 12 08 31 PM

@freeboub @mmttt89

@Nardeep
Copy link

Nardeep commented Jan 29, 2025

Here this is iPhone screenshot .Please check this one also

Screenshot 2025-01-29 at 12 11 34 PM

<Video

  // Ignores the silent switch on the device, allowing the video to play with sound even if the device is on silent mode
  ignoreSilentSwitch={'ignore'}
selectedAudioTrack={{ type: SelectedTrackType.INDEX, value: 0, }}
                  
  // Prevents the video from playing when the app is inactive or in the background
  playWhenInactive={false}
  playInBackground={false}

  // Disables the use of TextureView, which can optimize performance but might limit certain effects
  viewType={ViewType.SURFACE}

  // Hides the default media controls provided by the video player
  controls={false}

  // Disables focus on the video, which is useful for accessibility and UI focus management
  disableFocus={true}
  shutterColor="transparent"
  hideShutterView={true}
  poster={getEnvVars()?.videoUrl + seletedTukan?.thumbnail_url}
  ref={videoPlayerRef}
  

  source={{
    uri: getEnvVars().videoUrl + seletedTukan.media_url,
    bufferConfig:{
      minBufferMs: 10000, // Minimum buffer before playback starts
      maxBufferMs: 25000, // Maximum buffer allowed
      bufferForPlaybackMs: 300, // Buffer required to start playback
      bufferForPlaybackAfterRebufferMs: 2500, // Buffer required after rebuffering
    }
    ,textTracks:(seletedTukan?.caption_url&&seletedTukan?.caption_url?.length>0) ?[
      {
        title: 'English Subtitles',
        language: 'en',
        type: TextTrackType.VTT, 
       uri:getEnvVars().videoUrl +seletedTukan?.caption_url,
         // uri: 'https://d1wis83g01tmlr.cloudfront.net/captions/TranscribeJob-1734616100569-1734616134145-69.vtt',
        //uri: 'https://d1wis83g01tmlr.cloudfront.net/captions/TranscribeJob-1735809893287-1735809926774-68.srt',
      },
    ]:undefined
    
    ,
  
  }}
  
  onTextTracks={(e)=>{
    console.log("video "," onTextTracks >> "+JSON.stringify(e.textTracks))
  }}
  selectedTextTrack={{
    type: SelectedTrackType.LANGUAGE, // Type of track selection: 'index' or 'title'
    value: 'en', // Index of the selected subtitle track
  }}
  onTextTrackDataChanged={(e)=>{
 //   setSubtitle(e.subtitleTracks)
    console.log("video "," onTextTrackDataChanged ",JSON.stringify(e.subtitleTracks))
  }}
  subtitleStyle={{
   opacity:0
 
  }}



  style={{ width: width, height: height, backgroundColor:"red",aspectRatio:9/16}}
  resizeMode={'contain'}
  // resizeMode="cover" // Crops to fill the aspect ratio area
  posterResizeMode="cover"

  paused={paused}
  muted={false}
  onProgress={onProgress}
  onLoad={handleVideoLoad} // Log when the video loads
  onEnd={handleVideoEnd}
  repeat={false}
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Video is not showing full screen
3 participants