ios – Video UIView subview will not be exhibiting on display screen although video is taking part in


I’ve a VideoViewManager class which is used as a local part in my react native facet code.
VideoViewManager returns a category of sort UIView, VideoView.swift.

I’m attempting so as to add subview to this VideoView class, which is mainly a video participant that’s being returned from a Video Enhancing Api software
the subview -> (<VEPlaybackSDK.PlayablePreview: 0x7fabcd7467c0; baseClass = UIImageView; body = (0 0; 200 200); userInteractionEnabled = NO; backgroundColor = UIExtendedSRGBColorSpace 0 1 0 1; layer = <AVPlayerLayer: 0x600003048810>>)

although the addition of subview is profitable, and the video is taking part in, i can hear the audio of the video, however the precise video participant will not be seen on display screen.

Why is the video not seen? I can see the view aspect taking area in my viewport and the background colour can be altering, however the video i’m attempting to play, the participant will not be seen

these are my courses

class PlaybackController: NSObject, RCTBridgeModule {
  static func moduleName() -> String {
    return "PlaybackController"
  }
  
  var playbackManager: PlaybackManager!
  let editor = VideoEditorManager()
  
  // Create an occasion of VideoPlayerView
  var videoPlayerView: VideoPlayerView!
  
  // Override the designated initializer from NSObject
  override init() {
    tremendous.init()
    editor.editor.getLicenseState(completion: { isValid in
      print("license is legitimate right here")
      self.playbackManager = PlaybackManager(videoEditorModule: self.editor)
      self.playbackManager.addVideoContent(with: self.editor.selectedVideoContent)
      DispatchQueue.foremost.async {
        self.videoPlayerView = VideoPlayerView()
        
        self.playbackManager.setSurfaceView(with: self.videoPlayerView)
      }
    })
  }
}
class PlaybackManager: VideoEditorPlayerDelegate {

  init(videoEditorModule: VideoEditorManager) {
    self.videoEditorService = videoEditorModule.editor
    self.videoResolutionConfiguration = videoEditorModule.videoResolutionConfiguration
    self.playbackSDK = VEPlayback(videoEditorService: videoEditorService)
  }


func addVideoContent(with videoUrls: [URL]) {
    //  func addVideoContent(with videoUrls: URL) {
    let videoSequence = createVideoSequence(with: videoUrls)
    //    let videoSequence = VideoSequence(folderURL: "")
    self.videoSequence = videoSequence
    //    videoSequence.addVideo(at: videoFileURL)
    
    // Create VideoEditorAsset from related sequence
    // VideoEditorAsset is entity of VideoEditor used for plaback
    let videoEditorAsset = VideoEditorAsset(
      sequence: videoSequence,
      isGalleryAssets: true,
      isSlideShow: false,
      videoResolutionConfiguration: videoResolutionConfiguration
    )
    
    
    if videoEditorService != nil  {
      //        let videoPlayerView = VideoPlayerView()
      // Set present video asset to video editor service
      self.videoEditorService?.setCurrentAsset(videoEditorAsset)
      
      // self.setSurfaceView(with: videoPlayerView)
      
      // Setup preview render measurement
      self.setupRenderSize(videoSequence: videoSequence)
    }
  }
  
  
  // Gives video participant preview
  func setSurfaceView(with playerContainerView: VideoPlayerView!)  {
    DispatchQueue.foremost.async {
      // if VideoPlayer will not be nil
      if let playerContainerView = playerContainerView {
        print("playerContainerView==",playerContainerView)
        
        let playbackView = self.playbackSDK.getPlayableView(delegate: self)
        self.playbackView = playbackView
        
        // if subview of video participant is added already
        if self.isVideoAdded {
          
          print("playbackView ALREADY ADDED as a subview to playerContainerView")
        } else {
          print("playbackView subview not there presently, including")
          self.isVideoAdded = true
          playerContainerView.body = CGRect(x: 0, y: 0, width: 300, top: 300)
          
          playbackView.contentMode = .scaleAspectFit // or different appropriate content material mode
          playbackView.body = CGRect(x: 0, y: 0, width: 200, top: 200) // Regulate the width and top as wanted
          playbackView.backgroundColor = UIColor.inexperienced
          
          playerContainerView.addSubview(playbackView)
          playerContainerView.bringSubviewToFront(playbackView)
          playbackView.body = playerContainerView.bounds
          // Disable autoresizing masks in order that constraints work
             playbackView.translatesAutoresizingMaskIntoConstraints = false
             
 
          
          // Add Auto Format constraints to place playbackView
          playerContainerView.layoutSubviews()
          
          
          // Drive structure replace
          self.participant?.play(loop: true, fixedSpeed: true)
          
          print("playerContainerView.subviews== (playerContainerView.subviews)")
          
        }
      }
    }
    
  }


}
@objc(VideoPlayerManager)
class VideoPlayerManager: RCTViewManager {
    override func view() -> UIView! {
        return VideoPlayer()
    }
override static func requiresMainQueueSetup() -> Bool {
        return true
    }
}



class VideoPlayerView: UIView {


  override init(body: CGRect) {
      tremendous.init(body: body)
  }
  
  override func layoutSubviews() {
     tremendous.layoutSubviews()
     self.backgroundColor = UIColor.purple
     self.subviews.first?.body = self.bounds
   }

 required init?(coder aDecoder: NSCoder) {
      tremendous.init(coder: aDecoder)
  }
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles