iOS Question How to make Mediaplayer ignore the silence ringer switch setting?

Discussion in 'iOS Questions' started by Turbo3, Feb 4, 2015.

  1. Turbo3

    Turbo3 Active Member Licensed User

    How can we make Mediaplayer ignore the phone ringer silence switch setting?

    I did find that if I added the code to allow mediaplayer to play in the background and when the phone is off it also seems to have made it ignore the silence ringer switch setting.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It is a similar solution. You need to add this objective c code and call it before you initialize media player.

    Code:
    Sub Process_Globals
       
    Public App As Application
       
    Public NavControl As NavigationController
       
    Private Page1 As Page
       
    Private mp As MediaPlayer
    End Sub

    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       
    Dim jo As NativeObject = Me
       jo.RunMethod(
    "setAudioSession"Null)
       Page1.Initialize(
    "Page1")
       NavControl.ShowPage(Page1)
       mp.Initialize(
    File.DirAssets, "01.mp3""mp")
       mp.Play
    End Sub


    #If OBJC
    #import <AVFoundation/AVFoundation.h>
    - (void) setAudioSession {
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    BOOL ok;
    NSError *setCategoryError = nil;
    ok = [audioSession setCategory:AVAudioSessionCategoryPlayback
      error:&setCategoryError];
    if (!ok) {
      NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError);
    }
    }
    #end if
     
  3. Turbo3

    Turbo3 Active Member Licensed User

    Erel, Thanks that works great.

    Now back to how to read the WiFi SSID.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice