Comments (9)
Oh iOS it is recommended to use the MPVolumeView to allow users to control the volume. If you need programmatic control of the volume control for mixing or whatever reason then that's currently outside the scope of this project.
from streamingkit.
oh,i see .I have solved this problem by using MPVolumeView.thanks :)
from streamingkit.
For OS X?
from streamingkit.
StreamingKit doesn't have inbuilt volume control (you can see from the API). I'm happy to take pull requests. If you want to add it yourself, there's thousands of pages on the internet about how to do it. Even adding using STKAudioPlayer.appendFrameFilter
to change the volume by adjusting the amplitude of the frames wouldn't take very long.
from streamingkit.
Thanks! A framefilter worked for me. First take on implementation if others need it:
__weak __typeof(self)wself = self;
[self.stkAudioPlayer addFrameFilterWithName:@"Volume" afterFilterWithName:nil block:^(UInt32 channelsPerFrame, UInt32 bytesPerFrame, UInt32 frameCount, void *frames) {
float volume = wself.volume;
SInt16* samples16 = (SInt16*)frames;
SInt32* samples32 = (SInt32*)frames;
if (bytesPerFrame / channelsPerFrame == 2)
{
for (int i = 0; i < frameCount * channelsPerFrame; i += channelsPerFrame)
{
samples16[i] = samples16[i] *volume;
samples16[i + 1] = samples16[i + 1] *volume;
}
}
else if (bytesPerFrame / channelsPerFrame == 4)
{
for (int i = 0; i < frameCount * channelsPerFrame; i += channelsPerFrame)
{
samples32[i] = samples32[i] * volume;
samples32[i+1] = samples32[i+1] * volume;
}
}
else
{
return;
}
}];
from streamingkit.
I think on Mac (not iOS) you could use this as well...but I haven't tested it:
AudioUnitSetParameter (audioUnit, kHALOutputParam_Volume, kAudioUnitScope_Output, busNumber, volume, 0);
from streamingkit.
Thanks for the example code of your solution btw π
from streamingkit.
Ok I've added volume control support in master via the volume property. On iOS it uses a multi-channel mixer. Since the mixer will add a slight overhead, on iOS volume control won't work unless you pass in the STKAudioPlayerOptionEnableVolumeMixer options when initialising the player.
from streamingkit.
π
from streamingkit.
Related Issues (20)
- StreamingKit stopped working in iOS. HOT 1
- After seeking, PlayerState becomes "buffering" when a song finished playing. HOT 2
- Can I play MPEG-2 Transport Stream?
- Deadlock with playerMutex
- Weird bleeps and no metadata available when playing a SHOUTcast stream HOT 17
- cannot play .m4a files from remote url HOT 1
- play after seek time
- AUGraphStart crashes on simulator below iOS 14 HOT 1
- the player can't start use the network HOT 3
- didFinishPlayingQueueItemId never called sometimes HOT 3
- Crash HOT 5
- Just a question⦠HighRes audio
- ε―δ»₯ζζΎζ¬ε°ζδ»Άηι³ι’ε HOT 1
- Can I sync the StreamingKit player with lock screen player?
- Dose it support pitch ? HOT 1
- DSD Playback? HOT 5
- Very beginning of audio cut off [UPDATED with examples] HOT 2
- Failed to play audio url
- https://github.com/tumtumtum/StreamingKit
- Player cache issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from streamingkit.