How do i play/run video player and audio player at same time in xamarin IOS and Android?

How do i play/run video player and audio player at same time in xamarin IOS and Android?

Best Answer

Answers

  • RamohanRamohan Member ✭✭

    Hi @JGoldberger ,

    How to check video status completing or not?

    Thanks & Regards
    Ramohan Reddy

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @Ramohan

    On iOS:

    var tokenToRemoveObserver = NSNotificationCenter.DefaultCenter.AddObserver(
                AVPlayerItem.DidPlayToEndTimeNotification,
                VideoDidFinishPlaying,
                moviePlayerItem
                );
    
    public void VideoDidFinishPlaying(NSNotification notification)
        {
            // code to run when video finishes
        }
    

    When done you will want to remove the observer with:

     NSNotificationCenter.DefaultCenter.RemoveObserver(tokenToRemoveObserver);
    

    On Android, you can subscribe to the Completion event on the VideoView:

    videoView.Completion += VideoView_Completion;
    
    private void VideoView_Completion(object sender, EventArgs e)
        {
            // code to run when video finishes
        }
    
  • RamohanRamohan Member ✭✭

    @JGoldberger said:
    @Ramohan

    On iOS:

    var tokenToRemoveObserver = NSNotificationCenter.DefaultCenter.AddObserver(
                AVPlayerItem.DidPlayToEndTimeNotification,
                VideoDidFinishPlaying,
                moviePlayerItem
                );
    
    public void VideoDidFinishPlaying(NSNotification notification)
        {
            // code to run when video finishes
        }
    

    When done you will want to remove the observer with:

     NSNotificationCenter.DefaultCenter.RemoveObserver(tokenToRemoveObserver);
    

    On Android, you can subscribe to the Completion event on the VideoView:

    videoView.Completion += VideoView_Completion;
    

    private void VideoView_Completion(object sender, EventArgs e)
    {
    // code to run when video finishes
    }

    Thanks You @JGoldberger ,

  • RamohanRamohan Member ✭✭

    Hi @JGoldberger ,

    I am not able to getting video sound on device.
    In simulator its working fine .

    Thanks & Regards
    Ramohan Reddy

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    iOS or Android?

Sign In or Register to comment.