Page 1 of 1

How to mute programmatically?

Posted: 03 Oct 2016 21:24
by MidnightCoder
According to the documentation (http://cocoadocs.org/docsets/MobileVLCK ... TrackIndex), setting the "currentAudioTrackIndex" to -1 will effectively mute the player. However, on iOS, this property has type UInt (unsigned int). How do you assign a negative number to a UInt?

Re: How to mute programmatically?

Posted: 05 Oct 2016 16:43
by ssbmaccom
I would try to use media.currentAudioTrackIndex = (UInt)-1; which shall result in 0xFFFFFFFF and work.

Re: How to mute programmatically?

Posted: 06 Oct 2016 03:46
by MidnightCoder
I would try to use media.currentAudioTrackIndex = (UInt)-1; which shall result in 0xFFFFFFFF and work.
Thanks for taking the time to response to my question. I already tried that before posting the question but unfortunately, the compiler treats that as a syntax error:
Binary operator '-' cannot be applied to operands of type '(UInt).Type' (aka 'UInt.Type') and 'Int'
I found another way to mute but curious how to set -1 as the index as mentioned in the documentation.

Re: How to mute programmatically?

Posted: 06 Oct 2016 16:25
by ssbmaccom
You use clang in Xcode 8?
I just tried this in a brief sample and I do not even get a warning.

Code: Select all

int main(int argc, const char * argv[]) { @autoreleasepool { UInt x; x = (UInt)-1; NSLog( @"x is %uld = 0x%x", x, x ); } return 0; }
And console shows

Code: Select all

2016-10-06 16:22:48.412 UIntTest[70763:1076284] x is 4294967295ld = 0xffffffff Program ended with exit code: 0

Re: How to mute programmatically?

Posted: 06 Oct 2016 16:49
by MidnightCoder
I'm using Swift 3.0 w/ Xcode 8.

Re: How to mute programmatically?

Posted: 09 Oct 2016 14:17
by ssbmaccom
OK, one more reason I continue to use C and ObjectiveC ;-)