# MediaPlayer Bug in iOS 16

**URL:** <https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439>\
**Category:** Mobile\
**Tags:** unreal-engine, UE5-0, iOS, UE4-26, UE4-27, question\
**Created:** [November 8, 2022, 7:27am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439 "2022-11-08T07:27:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![B\_REX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/b_rex/32/982590_2.png) [@B\_REX](https://forums.unrealengine.com/u/B_REX)\
**Post date:** [November 8, 2022, 7:27am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/1 "2022-11-08T07:27:37Z")

</div>

Hi Folks,

we’re encountering problems with the implementation of the media player framework for the unreal engine and iOS16. What the guys at epic are doing is basically calling

(AVPlayerItem\* PlayerItem;) [[PlayerItem asset] loadValuesAsynchronouslyForKeys:@[@“tracks”] completionHandler:^ […]

to load the local asset and than (AVPlayer\* MediaPlayer;) [MediaPlayer replaceCurrentItemWithPlayerItem : PlayerItem];

to set the asset and

[MediaPlayer prerollAtRate:1.0f completionHandler:^(BOOL bFinished) […]

to start preloading. At this point the player doesn’t call the completionHandler anymore reliable since the release of iOS 16. Before everything was working flawless, but now most of the time the asset loading fails without errors. Any thoughts what might have changed with ios16? Probably it’s due to some threading issue. Any help highly welcome!

---

<div class="post-metadata">

**Author:** ![Aqshay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aqshay/32/598451_2.png) [@Aqshay](https://forums.unrealengine.com/u/Aqshay)\
**Post date:** [November 9, 2022, 9:53am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/2 "2022-11-09T09:53:36Z")

</div>

Oh my god, I just have the same problem, do you work on unreal 4.27 or 5?  
I can’t find a workaround for this one since it’s so random 😕

---

<div class="post-metadata">

**Author:** ![B\_REX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/b_rex/32/982590_2.png) [@B\_REX](https://forums.unrealengine.com/u/B_REX)\
**Post date:** [November 9, 2022, 10:42am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/3 "2022-11-09T10:42:25Z")

</div>

At least, we’re not alone 😃 It’s a custom build of the 4.26 branch. We still try to alter the AVMediaPlayer Plugin on a few lines, but so far it really doesn’t look very promising…

---

<div class="post-metadata">

**Author:** ![B\_REX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/b_rex/32/982590_2.png) [@B\_REX](https://forums.unrealengine.com/u/B_REX)\
**Post date:** [November 11, 2022, 12:52pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/5 "2022-11-11T12:52:27Z")

</div>

Could you check if this helps in your project too. It basically disables the prerolling in the avfmediaplayer. In our test project it was working, in the final project, it was still misbehaving, so it might not fix completely.

Copy the Plugin from the Engine to your Project Plugins Folder  
C:\Program Files\Epic Games[VERSION]\Engine\Plugins\Media\AvfMedia

Than replace the AvfMedia\Source\AvfMedia\Private\Player\AvfMediaPlayer.cpp with the attached file.

[AvfMediaPlayer.cpp](https://forums.unrealengine.com/uploads/short-url/aA7ku9BLXFBJU6xhg0GL4MXVSJw.cpp) (29.8 KB)

Afterwards delete the Plugin Intermediate and Binaries Folder and let the engine rebuild it.

---

<div class="post-metadata">

**Author:** ![Aqshay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aqshay/32/598451_2.png) [@Aqshay](https://forums.unrealengine.com/u/Aqshay)\
**Post date:** [November 16, 2022, 9:41am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/6 "2022-11-16T09:41:20Z")

</div>

Thx for the update.  
Do I need to rebuild Unreal to make this change, because we actually use the default engine downloaded with the epic launcher.

---

<div class="post-metadata">

**Author:** ![elpixolero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@elpixolero](https://forums.unrealengine.com/u/elpixolero)\
**Post date:** [November 16, 2022, 5:46pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/7 "2022-11-16T17:46:10Z")

</div>

No, it’s an official plugin, but if you copy it to your project plugin folder, it should recompile.

---

<div class="post-metadata">

**Author:** ![TDFactory](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TDFactory](https://forums.unrealengine.com/u/TDFactory)\
**Post date:** [November 20, 2022, 3:43pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/8 "2022-11-20T15:43:38Z")

</div>

Thank you for your hard work.  
Your solution may fix our project’s iOS 16 crash and media related bugs.  
Thanks again

---

<div class="post-metadata">

**Author:** ![Hansyuan\_Nb](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hansyuan_nb/32/561253_2.png) [@Hansyuan\_Nb](https://forums.unrealengine.com/u/Hansyuan_Nb)\
**Post date:** [December 12, 2022, 3:50am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/9 "2022-12-12T03:50:00Z")

</div>

Hi, did you slove the issue? Thanks

---

<div class="post-metadata">

**Author:** ![B\_REX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/b_rex/32/982590_2.png) [@B\_REX](https://forums.unrealengine.com/u/B_REX)\
**Post date:** [December 15, 2022, 8:12am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/10 "2022-12-15T08:12:42Z")

</div>

Yes, the altered Plugin fixes it. Since the newest MacOS version the MediaPlayer is broken there too, but can be fixed exactly the same way than on iOS. Just remove the if #if PLATFORM\_MAC code block and the #else/#endif and it should work.

---

<div class="post-metadata">

**Author:** ![Snowjeti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Snowjeti](https://forums.unrealengine.com/u/Snowjeti)\
**Post date:** [December 28, 2022, 7:31pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/11 "2022-12-28T19:31:24Z")

</div>

Hi everyone.  
I was going crazy on these video bugs until I found your posts. Thanks so much!  
I followed the instructions but now I am getting these errors while building for iOS.  
Do you have a solution for that, too? I would really appreciate it! ;-D

```auto

[2/9] Compile Module.AvfMediaFactory.cpp
UATHelper: Packaging (iOS): In file included from C:\***\Plugins\AvfMedia\Intermediate\Build\IOS\UE4\Shipping\AvfMedia\Module.AvfMedia.cpp:3:
UATHelper: Packaging (iOS): C:\***\Plugins\AvfMedia\Source\AvfMedia\Private\Player\AvfMediaPlayer.cpp:396:67: error: use of undeclared identifier 'GetAvfMediaPlayerDebugData'
UATHelper: Packaging (iOS): UE_LOG(LogTemp, Warning, TEXT("State of AVFMediaPlayer is %s"), *GetAvfMediaPlayerDebugData());
UATHelper: Packaging (iOS): ^
UATHelper: Packaging (iOS): C:\***\Plugins\AvfMedia\Source\AvfMedia\Private\Player\AvfMediaPlayer.cpp:614:9: error: use of undeclared identifier 'GetAvfMediaPlayerDebugData'
UATHelper: Packaging (iOS): return GetAvfMediaPlayerDebugData();
UATHelper: Packaging (iOS): ^
PackagingResults: Error: use of undeclared identifier 'GetAvfMediaPlayerDebugData'
PackagingResults: Error: use of undeclared identifier 'GetAvfMediaPlayerDebugData'
UATHelper: Packaging (iOS): C:\***\Plugins\AvfMedia\Source\AvfMedia\Private\Player\AvfMediaPlayer.cpp:623:26: error: out-of-line definition of 'GetAvfMediaPlayerDebugData' does not match any declaration in 'FAvfMediaPlayer'
UATHelper: Packaging (iOS): FString FAvfMediaPlayer::GetAvfMediaPlayerDebugData() const
UATHelper: Packaging (iOS): ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
PackagingResults: Error: out-of-line definition of 'GetAvfMediaPlayerDebugData' does not match any declaration in 'FAvfMediaPlayer'
UATHelper: Packaging (iOS): 3 errors generated.

```

---

<div class="post-metadata">

**Author:** ![B\_REX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/b_rex/32/982590_2.png) [@B\_REX](https://forums.unrealengine.com/u/B_REX)\
**Post date:** [January 10, 2023, 10:12am UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/12 "2023-01-10T10:12:23Z")

</div>

> [@Snowjeti](#):
>
> `GetAvfMediaPlayerDebugData`

Ah, sorry about that. We added a new function for further debugging. Just delete the whole GetAvfMediaPlayerDebugData function from the cpp file. The error occures because the function is not defined in the AvfMediaPlayer.h file. Or use the attached plugin, it’s the one we are using currently.  
[AvfMedia.zip](https://forums.unrealengine.com/uploads/short-url/rk2rYUNkybJdVfatG9qUKN8URTs.zip) (46.4 KB)

---

<div class="post-metadata">

**Author:** ![jr\_visionate1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jr\_visionate1](https://forums.unrealengine.com/u/jr_visionate1)\
**Post date:** [January 13, 2023, 4:50pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/13 "2023-01-13T16:50:59Z")

</div>

Hi.

how can i build the plugin on a mac? I always get an error message: …could not be compiled. Try rebuilding from source manually.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![apmason](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/apmason/32/88719_2.png) [@apmason](https://forums.unrealengine.com/u/apmason)\
**Post date:** [January 19, 2023, 5:23pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/14 "2023-01-19T17:23:31Z")

</div>

This worked, thank you!

---

<div class="post-metadata">

**Author:** ![TTF\_eric1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TTF\_eric1](https://forums.unrealengine.com/u/TTF_eric1)\
**Post date:** [October 17, 2024, 2:05pm UTC](https://forums.unrealengine.com/t/mediaplayer-bug-in-ios-16/686439/15 "2024-10-17T14:05:53Z")

</div>

Any chance you guys have updated your version of the plugin to work in UE5.3?

thx-e
