How to mute programmatically?

iOS, iPad, iPhone, tvOS specific usage questions
MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

How to mute programmatically?

Postby MidnightCoder » 03 Oct 2016 21:24

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?

ssbmaccom
Cone that earned his stripes
Cone that earned his stripes
Posts: 184
Joined: 26 Nov 2015 15:21
Operating System: Mac OS, iOS, tvOS

Re: How to mute programmatically?

Postby ssbmaccom » 05 Oct 2016 16:43

I would try to use media.currentAudioTrackIndex = (UInt)-1; which shall result in 0xFFFFFFFF and work.

MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

Re: How to mute programmatically?

Postby MidnightCoder » 06 Oct 2016 03:46

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.

ssbmaccom
Cone that earned his stripes
Cone that earned his stripes
Posts: 184
Joined: 26 Nov 2015 15:21
Operating System: Mac OS, iOS, tvOS

Re: How to mute programmatically?

Postby ssbmaccom » 06 Oct 2016 16:25

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

MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

Re: How to mute programmatically?

Postby MidnightCoder » 06 Oct 2016 16:49

I'm using Swift 3.0 w/ Xcode 8.

ssbmaccom
Cone that earned his stripes
Cone that earned his stripes
Posts: 184
Joined: 26 Nov 2015 15:21
Operating System: Mac OS, iOS, tvOS

Re: How to mute programmatically?

Postby ssbmaccom » 09 Oct 2016 14:17

OK, one more reason I continue to use C and ObjectiveC ;-)


Return to “VLC for iOS, iPadOS and Apple TV”

Who is online

Users browsing this forum: No registered users and 8 guests