AVPlayer.OpenFile
-----------------

Opens an audio file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [AVPlayer](component_AVPlayer.md) | [7.1](newinversion71.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "AVPlayer.OpenFile"; Path ) 

**MBS**( **"AVPlayer.OpenFile";** /\* Opens an audio file. \*/  
**$Path**) /\* The native file path to the movie file.e.g. "/Test.mov" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Path | The native file path to the movie file. | "/Test.mov" |

### Result

Returns player reference number or error.

### Description

Opens an audio file.  
Returns the reference number which must be released with [AVPlayer.Release](AVPlayerRelease.md) function.  
  
See [WMFP.Create](WMFPCreate.md) for Windows.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
### Examples

Open file:

 Set Variable \[$player ; Value:MBS ("AVPlayer.OpenFile"; AVPlayer::FilePath )\]  
If \[MBS ("IsError")\]  
 Show Custom Dialog \["Error loading audio file."; $player \]  
 Exit Script \[\]  
End If  
Set Field \[AVPlayer::Duration ; MBS ("[AVPlayer.GetDuration](AVPlayerGetDuration.md)"; $player )\]  
Set Field \[AVPlayer::Rate ; MBS ("[AVPlayer.GetRate](AVPlayerGetRate.md)"; $$Player )\]  
Set Field \[AVPlayer::Volume ; MBS ("[AVPlayer.GetVolume](AVPlayerGetVolume.md)"; $$Player )\]  
Set Variable \[$$player ; Value:$player \]  
### See also

- [AVPlayer.GetDuration](AVPlayerGetDuration.md)
- [AVPlayer.GetRate](AVPlayerGetRate.md)
- [AVPlayer.GetVolume](AVPlayerGetVolume.md)
- [AVPlayer.OpenContainer](AVPlayerOpenContainer.md)
- [AVPlayer.OpenURL](AVPlayerOpenURL.md)
- [AVPlayer.Release](AVPlayerRelease.md)
- [IsError](IsError.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [WMFP.Create](WMFPCreate.md)

### Example Databases

- [Mac and iOS/AVPlayer](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/AVPlayer.shtml#1ScriptAnchor_)

This function checks for a license.

Created 3th February 2017 , last changed 18th June 2022

  
[AVPlayer.OpenContainer](AVPlayerOpenContainer.md) - [AVPlayer.OpenURL](AVPlayerOpenURL.md)

[HTML Version](AVPlayerOpenFile.shtml)