大牛直播sdk简单播放端demo使用

本文介绍了如何集成大牛直播SDK,包括导入依赖jar,遵循特定包名进行初始化,以及如何接收推流和使用播放器进行直播功能。同时提到了不同平台的推送端和播放端应用名称。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

集成

导入依赖jar


官方例子中的SmartPlayerJni

集成注意:该java必须处在com.daniulive.smartplayer包名下,否则init会出错。

public class SmartPlayerJni {	
	 /**
	 * Initialize Player.
	 *
	 * @param ctx: get by this.getApplicationContext()
	 *
	 * <pre>This function must be called firstly.</pre>
	 *
	 * @return player handle if successful, if return 0, which means init failed. 
	 */
	 
	 public native long SmartPlayerInit(Object ctx);
	  	
	 /**
	  * Set callback event
	  * 
	  * @param callback function
	  * 
	  * @return {0} if successful
	  */
	 public native int SetSmartPlayerEventCallback(long handle, SmartEventCallback callback);
	 
	 /**
	  * Set Video HW decoder, if support HW decoder, it will return 0
	  * 
	  * @param isHWDecoder: 0: software decoder; 1: hardware decoder.
	  * 
	  * @return {0} if successful
	  */
	 public native int SetSmartPlayerVideoHWDecoder(long handle, int isHWDecoder);
	 
	 /**
	 * Set Surface view.
	 *
	 * @param handle: return value from SmartPlayerInit()
	 *
	 * @param glSurface: surface view
	 * 
	 * <pre> NOTE: if not set or set surface with null, it will playback audio only. </pre> 
	 *
	 * @return {0} if successful
	 */
	 public native int SmartPlayerSetSurface(long handle, Object surface);
	
	 
	 /**
	 * Set External Render.
     *
	 * @param handle: return value from SmartPlayerInit()
	 *
	 * @param external_render:  External Render
	 * 
	 * @return {0} if successful
	 */
	 public native int SmartPlayerSetExternalRender(long handle, Object external_render);
 

	 /**
	  * Set AudioOutput Type
	  * 
	  * @param handle: return value from SmartPlayerInit()
	  * 
	  * @param use_audiotrack: 
	  * 
	  * <pre> NOTE: if use_audiotrack with 0: it will use auto-select output devices; if with 1: will use audiotrack mode. </pre> 
	  * 
	 * @return {0} if successful
	  */
	 public native int SmartPlayerSetAudioOutputType(long handle, int use_audiotrack);	
	 
	 
	 /**
	  * Set buffer
	  * 
	  * @param handle: return value from SmartPlayerInit()
	  * 
	  * @param buffer: 
	  * 
	  * <pre> NOTE: Unit is millisecond, range is 200-5000 ms </pre> 
	  * 
	 * @return {0} if successful
	  */
	 public native int SmartPlayerSetBuffer(long handle, int buffer);
	 
	 
	 /**
	  * Set mute or not
	  * 
	  * @param is_mute: if with 1:mute, if with 0: does not mute
	  * 
	  * @return {0} if successful
	  */
	 public native int SmartPlayerSetMute(long handle, int is_mute);
	 
	 
	 /**
	  * It's only used when playback RTSP stream
	  *
	  * Default with UDP mode
	  *
	  * @param isUsingTCP: if with 1, it will via TCP mode, while 0 with UDP mode
	  *
	  * @return {0} if successful
	  */
	 public native int SmartPlayerSetRTSPTcpMode(long handle, int is_using_tcp);
	  	  	
	 /**
	 * Set playback orientation.
	 *
	 * @param handle: return value from SmartPlayerInit()
	 * 
	 * @param surOrg: current orientation,  PORTRAIT 1, LANDSCAPE with 2
	 *
	 * @return {0} if successful
	 */
	 public native int SmartPlayerSetOrientation(long handle, int surOrg);
		  	
	 /**
	 * Start playback stream
	 *
	 * @param handle: return value from SmartPlayerInit()
	 * 
	 * @param uri: playback uri
	 *
	 * @return {0} if successful
	 */
	 public native int SmartPlayerStartPlayback(long handle, String uri);
		  	
	 /**
	 * Close player instance.
	 *
	 * @param handle: return value from SmartPlayerInit()
	 * 
	 * <pre> NOTE: it could not use player handle after call this function. </pre> 
	 *
	 * @return {0} if successful
	 */
	 public native int SmartPlayerClose(long handle);
}



接收推流

public class SmartPlayer extends Activity {
	    
    private SurfaceView sSurfaceView = null;   
	
	private long playerHandle = 0;
	
	private static final int PORTRAIT = 1;		//竖屏
	private static final int LANDSCAPE = 2;		//横屏
	private static final String TAG = "SmartPlayer";
	
	private SmartPlayerJni libPlayer = null;
	
	private int currentOrigentation = PORTRAIT;
	
	private boolean isPlaybackViewStarted = false;
	
	private String playbackUrl = null;
	
	private boolean isMute = false;
	
	private boolean isHardwareDecoder = false;
	
	Button btnPopInputText;
	Button btnPopInputUrl;
	Button btnMute;
    Button btnStartStopPlayback;
	Button btnHardwareDecoder;
    TextView txtCopyright;
    TextView txtQQQun;
    
    LinearLayout lLa
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值