B4A 调用 饺子播放器 JiaoZiVideoPlayer

  • Post author:
  • Post category:其他


B4A 是非常优秀的入门级安卓开发工具

https://www.b4x.com/


饺子浏览器,高度自定义的安卓视频框架

https://github.com/Jzvd/JZVideo/


仅需要几行代码,就可以将让app具备视频播放的功能,下面的代码演示最基本的流媒体播放。

播放源来自网络搜索,湖南卫视的源

#Region  Project Attributes 
	#ApplicationLabel: B4A Example
	#VersionCode: 1
	#VersionName: 
	'SupportedOrientations possible values: unspecified, landscape or portrait.
	#SupportedOrientations: unspecified
	#CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region
#AdditionalJar: jiaozivideoplayer-7.7.0.aar
#IncludeTitle:false
Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	Dim jzplayer As JavaObject
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("Layout")
	Dim context As JavaObject
	context.InitializeContext
	Dim a As Object
	a=context.RunMethod("getActivityBAContext",Null)
	jzplayer.InitializeNewInstance("cn.jzvd.JzvdStd",Array(a))
	jzplayer.RunMethod("setUp",Array("http://219.151.31.38/liveplay-kk.rtxapp.com/live/program/live/hnwshd/4000000/mnf.m3u8","湖南卫视"))
	Activity.AddView(jzplayer, 0, 0, 100%x, 100%y)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

#if Java
public Object getActivityBAContext() {
   return this.activityBA.context;
}
#End If

附上饺子播放器arr库下载地址:

https://repo.maven.apache.org/maven2/cn/jzvd/jiaozivideoplayer/7.7.0/jiaozivideoplayer-7.7.0.aar

默认的包不大,只包含了系统自带播放器的封装,如果想要用 哔哩哔哩的 ijkplayer 或 谷歌的ExoPlayer 内核播放,还需要研究下 github上的


源码>切换播放内核



版权声明:本文为spooking原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。