0

I im using ExoPlayer and need to call private function from another class:

to call function:

getRendererBuilder(MediaSourceType, Uri, MediaUtil.MediaType)

I got MediaSourceType, Uri and MediaUtil.MediaType so because this function is hidden in class it is defined like this:

   public class EMVideoView
          extends RelativeLayout
          implements AudioCapabilitiesReceiver.Listener, VideoTextureView.OnSizeChangeListener {
   private RenderBuilder getRendererBuilder(MediaSourceType renderType, Uri uri, MediaUtil.MediaType defaultMediaType)
   {
       switch (renderType)
       {
           case HLS: 
               return new HlsRenderBuilder(getContext().getApplicationContext(), getUserAgent(), uri.toString());
           case DASH: 
               return new DashRenderBuilder(getContext().getApplicationContext(), getUserAgent(), uri.toString());
           case SMOOTH_STREAM: 
               return new SmoothStreamRenderBuilder(getContext().getApplicationContext(), getUserAgent(), uri.toString());
        }
        return new RenderBuilder(getContext().getApplicationContext(), getUserAgent(), uri.toString());
   }

I im working with this class

  public class ExoPlayer extends ViewWrapper<EMVideoView> {
        // HERE I NEED TO CALL getRendererBuilder and pass the parameters
        EMVideoView.setVideoURI(Uri, getRendererBuilder(renderType, uri, defaultMediaType));
  }

How to call private function getRendererBuilder from my class? I im beginner and need to finish wrapper library...so example code will be very nice to learn.

Thanks.

Rion Williams
  • 74,820
  • 37
  • 200
  • 327
John
  • 147
  • 1
  • 13
  • 1
    There is a reason this method is private. It is not meant to be called from outside the class. If you really must call it you can use reflection. – Henry May 17 '16 at 17:58
  • 1
    In short, private methods are private for a reason: to prevent external entities from calling them. There might be a way around it using reflection but then stop and rethink your approach if this is the only way \ – blurfus May 17 '16 at 17:59
  • Reflection is a bad idea. You should rethink your issue.Are you absolutley required to call that? is it possible that there's another class that can do that for you? – Richard Barker May 17 '16 at 18:01
  • I im using google ExoPlayer for android..when i starturi stream plays and is default selected and picture quality is very low...using above function i will set video quality to SMOOTH_STREAM and picture will be high quality...i im beginner in calling private classes is someone can give example to call it...thanks – John May 17 '16 at 18:12

0 Answers0