---
title: sampleLocation()
framework: MediaExtension
role: symbol
role_heading: Instance Method
platforms: [macOS 14.0+]
path: mediaextension/mesamplecursor/samplelocation()
---

# sampleLocation()

Returns the location and byte source of the sample indicated by the cursor.

## Declaration

```swift
optional func sampleLocation() throws -> MESampleLocation
```

## Return Value

Return Value A sample location.

## Discussion

Discussion Sample data needs to be contiguous. If the sample data isn’t contiguous or the cursor doesn’t support this method, it fails with the error MEError.Code.locationNotAvailable. In this case, use loadSampleBufferContainingSamples(to:completionHandler:) to load the data. If it’s not possible to implement this method, implement estimatedSampleLocation() to get an estimated sample location, and refineSampleLocation(_:refinementData:refinementDataLength:refinedLocation:) to analyze this data and provide precise location and size info.

## See Also

### Sending samples to a pipeline

- [chunkDetails()](mediaextension/mesamplecursor/chunkdetails().md)
- [loadSampleBufferContainingSamples(to:completionHandler:)](mediaextension/mesamplecursor/loadsamplebuffercontainingsamples(to:completionhandler:).md)
