'Code module
#Region Project Attributes
#ApplicationLabel: B4i Example
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 7
#End Region
#PlistExtra:<key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict>
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private Timer1 As Timer
Private player1 As NativeObject
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
player1 = CreatePlayer("http://www.mysite.com/mp3")
player1.RunMethod("play", Null)
Timer1.Initialize("Timer1", 1000)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick
Dim status As Int = player1.GetField("status").AsNumber
Log ( "status " & status )
Dim rate As Int = player1.GetField("rate").AsNumber
Log ( "rate " & rate )
Log ( "currentTime: " & player1.RunMethod("currentTime", Null) ) '???
End Sub
Sub CreatePlayer(url As String) As NativeObject
Dim u As NativeObject
u = u.Initialize("NSURL").RunMethod("URLWithString:", Array(url))
Dim player As NativeObject
player = player.Initialize("AVPlayer").RunMethod("alloc", Null).RunMethod("initWithURL:", Array(u))
Return player
End Sub