iOS Question muted property with the AVPlayer not working

XMan2012

Member
Licensed User
Longtime User
Hello,

Based on the solution given here,
https://www.b4x.com/android/forum/t...-at-the-same-time-possible.70195/#post-445833

I wanted to use the mute property, but I can't seem to figure it out.
I am getting an error:
Method not found: muted, target: <AVPlayer: 0x165699e0>

Here the code with the muted (which I do not know how to implement):
B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private player1, player2, player3 As NativeObject
End Sub

Private Sub Application_Start ( Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.LoadLayout("1")
   Nav.ShowPage(Page1)
   player1 = CreatePlayer("http://peace.str3am.com:6350")
   player2 = CreatePlayer("http://cast.sc1.shoutcaststreaming.us:8080")
   player3 = CreatePlayer("http://sc1.christiannetcast.com:9058")
   player1.RunMethod("play", Null)
   player2.RunMethod("play", Null)
   player3.RunMethod("play", Null)
End Sub
Sub muteplayer1
'Tried this
player1.RunMethod("muted", Null)
'This gives the error. Of course this would not do nothing. But do not really know how to implement this in B4i
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

In swift on my mac I was doing this and it was fine:
B4X:
'Example:
player1.muted = true

I am trying to acheive this for each player I created.

Reference:
https://developer.apple.com/library...r_Class/#//apple_ref/occ/instp/AVPlayer/muted


Thank you very much
 
Top