#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'DEFINE - ion
Private ion As Object
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
'DEFINE - hw
Dim HW As Byte = 1
'DEFINE - sw
Dim SW As Byte = 2
'DEFINE - decoder
Dim Decoder As Byte = SW
'DEFINE - Subtitle
Dim Subtitle(0) As String = Array As String(VideoClub.MovieSubtitle)
'DEFINE - Intent
Dim Intent1 As Intent
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
'INITIALIZE - Movie
Intent1.Initialize(Intent1.ACTION_VIEW, VideoClub.MovieURL)
'CHECK - Trailer
If (VideoClub.MovieURL.Contains("trailer") = True) Then
'SET - Decoder
Decoder = HW
'SET - Subtitle
Intent1.PutExtra("subs", Subtitle)
Intent1.PutExtra("subs.name", "Croatian")
Intent1.PutExtra("subs.filename", "NAME.SRT")
Intent1.PutExtra("subs.enable", Subtitle)
End If
'SET - Title
Intent1.PutExtra("title", VideoClub.MovieTitle)
'SET - Data Type
Intent1.SetType("application/x-mpegURL")
'SET - S/W Decoder
Intent1.PutExtra("decode_mode", Decoder)
'SET - MX Player
Intent1.SetComponent("com.mxtech.videoplayer.pro")
'START - MX Player
StartActivityForResult(Intent1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ion_Event (MethodName As String, Args() As Object) As Object
'CHECK - Exit Player
If (Args(0) = 0) Then
'EXIT - Player
Activity.Finish
End If
'RETURN - False
Return False
End Sub
Sub StartActivityForResult(i As Intent)
'INITIALIZE - JavaObject
Dim jo As JavaObject = GetBA
'CREATE - Event
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
'RUN - Method
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
'DEFINE - JavaObject
Dim jo As JavaObject
'DEFINE - cls
Dim cls As String = Me
'GEt - Name
cls = cls.SubString("class ".Length)
'INITIALIZE - cls
jo.InitializeStatic(cls)
'RETURN - ProcessBA
Return jo.GetField("processBA")
End Sub