I
I
Ivan Somov2013-11-14 17:37:20
iOS
Ivan Somov, 2013-11-14 17:37:20

How to control system sound in iOS (html5 + cordova)?

I am making an application on phonegap for iOS, the task is to play streaming audio. For these purposes, html5 is used, (everything is fine with this), in addition, you need to control the system sound from the application itself. I figured out how plugins are implemented on phonegap and more or less successfully filed my own, I can call a function from js and it normally accesses the phone’s system resources through the phonegap class, and this is where my stupor comes in. It is not clear what exactly is responsible for the system volume. tried like this (find out the current volume)

float vol = [[AVAudioSession sharedInstance] outputVolume];
NSLog(@"output volume: %1.2f dB", 20.f*log10f(vol+FLT_MIN));

zeros always come, I tried to cling to AudioServices, MPMusicPlayerController, and everything that was found on request (I googled frankly a little) - but so far to no avail, I'm a complete noob in programming for apples, please give me a hint in which direction to dig.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
deleted-mezhevikin, 2013-11-14
@jsom

I don’t understand your fongaps, but in cocoaotach it’s done like this:

Add to MediaPlayer.framework to the project, include it in the file:


#import "MediaPlayer/MediaPlayer.h"


// получаем значение
 float volume = [MPMusicPlayerController applicationMusicPlayer].volume;
 
// устанавливаем   
 [[MPMusicPlayerController applicationMusicPlayer] setVolume:1.0];

I
Ivan Somov, 2013-11-15
@jsom

super, everything worked! confuses that the volume parameter

float volume = [MPMusicPlayerController applicationMusicPlayer].volume

Judging by the docks, the status of Deprecated for ios7, although it gives the value of the norms, checked it on the device. Is this a threat in the future?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question