<!--
{
  "availability" : [
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaExtension",
  "identifier" : "/documentation/MediaExtension/MEByteSource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "MediaExtension"
    ],
    "preciseIdentifier" : "c:objc(cs)MEByteSource"
  },
  "title" : "MEByteSource"
}
-->

# MEByteSource

Provides read access to the data in a media asset file.

```
class MEByteSource
```

## Overview

Media Toolbox passes an `MEByteSource` instance for the media asset’s primary file when it initializes an [`MEFormatReader`](/documentation/MediaExtension/MEFormatReader) object. The format reader may call [`byteSourceForRelatedFileName(_:)`](/documentation/MediaExtension/MEByteSource/byteSourceForRelatedFileName(_:)) to request additional byte sources for related files in the same directory as the primary file.

## Topics

### Inspecting a byte source

[`fileName`](/documentation/MediaExtension/MEByteSource/fileName)

The name of the file for the byte source.

[`fileLength`](/documentation/MediaExtension/MEByteSource/fileLength)

The length of the byte source file.

[`contentType`](/documentation/MediaExtension/MEByteSource/contentType)

The format of the byte source file.

[`relatedFileNamesInSameDirectory`](/documentation/MediaExtension/MEByteSource/relatedFileNamesInSameDirectory)

An array of related file names in the parent directory of the byte source file.

### Performing operations on a byte source

[`-  availableLengthAtOffset:`](/documentation/MediaExtension/MEByteSource/availableLength(at:))

Gets the number of available bytes from the offset within the byte source.

[`-  byteSourceForRelatedFileName:error:`](/documentation/MediaExtension/MEByteSource/byteSourceForRelatedFileName(_:))

Creates a new byte source for a related file.

[`-  readDataOfLength:fromOffset:completionHandler:`](/documentation/MediaExtension/MEByteSource/read(length:from:completionHandler:))

Reads bytes from a byte source into a data object.

[`-  readDataOfLength:fromOffset:toDestination:bytesRead:error:`](/documentation/MediaExtension/MEByteSource/readDataOfLength:fromOffset:toDestination:bytesRead:error:)

Reads bytes from a byte source into a buffer.

[`-  readDataOfLength:fromOffset:toDestination:completionHandler:`](/documentation/MediaExtension/MEByteSource/readDataOfLength:fromOffset:toDestination:completionHandler:)

Reads bytes from a byte source into a buffer.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)