AddMutableTrack mediaType string value

Kevin O'Brien 20 Reputation points
2024-04-16T21:54:22.5166667+00:00

I'm using Swift AVFoundation in MAUI to perform audio file manipulation.

As part of that I need to use the AddMutableTrack method.

Swift's documentation says to use:

let compositionAudioTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: kCMPersistentTrackID_Invalid)

The C# MAUI code version of addMutableTrack accepts a string for the first parameter rather than an object:

var compositionAudioTrack = composition.AddMutableTrack("mediaType??", 0);

For Swift's AVMediaType.audio value, what is the equivalent C# MAUI value for this mediaType parameter in addMutableTrack?

For reference, composition is declared using:

var composition = new AVMutableComposition();

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,890 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 56,531 Reputation points
    2024-04-17T01:18:16.99+00:00

    you should be using the objective-c documentation, as those are the interfaces that C# can call. C# does not support calling swift api's:

    https://developer.apple.com/documentation/avfoundation/avmutablecomposition/1387601-addmutabletrackwithmediatype?language=objc

    if you look at docs its just a typedef for NSString:

    typedef NSString *AVMediaType;
    

    and its values are all global constants defined in a module and exported via the .h file

    AVMediaFormat.h

    the c# wrapper is:

    https://learn.microsoft.com/en-us/dotnet/api/avfoundation.avmediatype?view=xamarin-ios-sdk-12

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful