'How to Control iOS device volume with Unity?
I developed Enterprise App, and installed it to my iPad.
The problem is that the iPad will be built in the wall, so it will not be possible to access the volume buttons.
I want to control the volume during the exhibition. I made UIButtons "-" and "+" to control the volume of the device instead of real volume button, not the Unity audio component's volume. I researched several times, so now what should I do in Unity?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
public class IOSManager : MonoBehaviour {
public static IOSManager _instance;
[DllImport("__Internal")]
private static extern void iosVolumeMinus();
private static extern void iosVolumePlus();
void Awake(){
_instance = this;
}
public void CallMinusFunc()
{
iosVolumeMinus();
}
public void CallPlusFunc()
{
iosVolumePlus();
}
}
Well, I tried somethings and realized that MPMusicPlayerController And MPVolumeView may work, but had some problems.
If I use MPMusicPlayerController I get
alert : 'volume' is deprecated: first deprecated in iOS 7.0 - Use MPVolumeView for volume control.
But if I use MPVolumeView I get
alert : Incomplete definition of type 'struct objc_class'.
It is my first time developing an iOS app, so I don't know what the problem is.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

