2017-05-18 11 views
6

मैं एक व्रत के भीतर एक ExoPlayerView प्रदर्शित करने के लिए कोशिश कर रहा हूँ में ExoPlayer प्रदर्शित एक और ExoPlayer (चित्र में चित्र) डालने: enter image description hereएंड्रॉयड -, एक चक्र

मैं गोलाकार कोनों के साथ एक फ्रेम के अंदर 2 खिलाड़ी डालने की कोशिश की है (this answer और this one दोनों) लेकिन खिलाड़ी हमेशा पैरेंट फ्रेम से बचेंगे और वीडियो के पूर्ण आयत को आकर्षित करेंगे।

मुझे this solution मिला जो एक GLSurfaceView का उपयोग करता है, हालांकि यह समाधान क्लासिक मीडियाप्लेयर का उपयोग करता है और ExoPlayer नहीं।

+0

आप समाधान आप लिंक का उपयोग कर और GLSurfaceView का उपयोग कर, जैसा कि आपने ExoPlayer के साथ एक SurfaceView का उपयोग करेंगे की कोशिश की? (सतह श्रोता को स्थापित करना और सतह को एक्सपोप्लेयर में पास करना) – etan

+0

कोई भी इसमें भाग रहा है, समाधान SurfaceViews –

उत्तर

0

इसके लिए आपको एक कस्टम कंटेनर बनाना होगा। इसे आज़माएं और इसमें प्लेयर दृश्य रखें।

public class RoundFrameLayout extends FrameLayout { 

private final Path clip = new Path(); 

private int posX; 
private int posY; 
private int radius; 

public RoundFrameLayout(Context context) { 
    this(context,null); 

} 

public RoundFrameLayout(Context context, AttributeSet attrs) { 
    this(context, attrs,0); 
} 

public RoundFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { 
    super(context, attrs, defStyleAttr); 
    // We can use outlines on 21 and up for anti-aliased clipping. 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
     setClipToOutline(true); 
    } 
} 

@Override 
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) { 
    posX = Math.round((float) width/2); 
    posY = Math.round((float) height/2); 

    // noinspection NumericCastThatLosesPrecision 
    radius = (int) Math.floor((float) Math.min(width, height)/2); 

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
     setOutlineProvider(new OutlineProvider(posX, posY, radius)); 
    } else { 
     clip.reset(); 
     clip.addCircle(posX, posY, radius, Direction.CW); 
    } 
} 

@Override 
protected void dispatchDraw(Canvas canvas) { 
    // Not needed on 21 and up since we're clipping to the outline instead. 
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { 
     canvas.clipPath(clip); 
    } 

    super.dispatchDraw(canvas); 
} 

@Override 
public boolean onInterceptTouchEvent(MotionEvent event) { 
    // Don't pass touch events that occur outside of our clip to the children. 
    float distanceX = Math.abs(event.getX() - posX); 
    float distanceY = Math.abs(event.getY() - posY); 
    double distance = Math.hypot(distanceX, distanceY); 

    return distance > radius; 
} 

@TargetApi(Build.VERSION_CODES.LOLLIPOP) 
static class OutlineProvider extends ViewOutlineProvider { 

    final int left; 
    final int top; 
    final int right; 
    final int bottom; 

    OutlineProvider(int posX, int posY, int radius) { 
     left = posX - radius; 
     top = posY - radius; 
     right = posX + radius; 
     bottom = posY + radius; 
    } 

    @Override 
    public void getOutline(View view, Outline outline) { 
     outline.setOval(left, top, right, bottom); 
    } 

} 

}

+0

के बजाय TextureViews का उपयोग करना है जैसा कि सवाल में बताया गया है, यह समाधान काम नहीं करता है क्योंकि खिलाड़ी गोलाकार कोनों का सम्मान नहीं करता है पैरेंट फ्रेम के। –

संबंधित मुद्दे