iphone - AVPlayer volume control while playing Video -
i working on custom video player using avplayer
class in want implement volume control using uislider
control.
i have done this:
nsmutablearray *allaudioparams = [nsmutablearray array]; avmutableaudiomixinputparameters *audioinputparams =[avmutableaudiomixinputparameters audiomixinputparameters]; [audioinputparams setvolume:volumeslider.value attime:kcmtimezero]; [allaudioparams addobject:audioinputparams]; avmutableaudiomix *audiozeromix = [avmutableaudiomix audiomix]; [audiozeromix setinputparameters:allaudioparams]; [self.playeritem setaudiomix:audiozeromix];
but not working me can please suggest me other solution have done r&d not able find proper solution.
thanks.
you can use below code change volume :
nsarray *audiotracks = [asset trackswithmediatype:avmediatypeaudio]; nsmutablearray *allaudioparams = [nsmutablearray array]; (avassettrack *track in audiotracks) { avmutableaudiomixinputparameters *audioinputparams = [avmutableaudiomixinputparameters audiomixinputparameters]; [audioinputparams setvolume:volume attime:kcmtimezero]; [audioinputparams settrackid:[track trackid]]; [allaudioparams addobject:audioinputparams]; } avmutableaudiomix *audiomix = [avmutableaudiomix audiomix]; [audiomix setinputparameters:allaudioparams]; [playeritem setaudiomix:audiomix];
Comments
Post a Comment