# Media Player Get Duration returns 0

**URL:** <https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163>\
**Category:** Cinematics & Media\
**Tags:** unreal-engine, question\
**Created:** [September 4, 2018, 4:04pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163 "2018-09-04T16:04:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![E1andri1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E1andri1](https://forums.unrealengine.com/u/E1andri1)\
**Post date:** [September 4, 2018, 4:04pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/1 "2018-09-04T16:04:11Z")

</div>

Hello,

I’m trying to get the overall duration of a video file in a media player, because I want to rewind it at half time and restart it from the beginning.

I tried to use a reset function called by a timer that fires every 0.5 \* duration seconds. Here’s the blueprint:

[Blueprint Pastebin](https://blueprintue.com/blueprint/gufgm6f0/)

However, it doesn’t work, because the Get Duration Node returns a solid 0 no matter what file I specify. I also switched between Media Players (VLC and the Native windows media player) all with same result.

What am I doing wrong?

Kind regards and thank you

---

<div class="post-metadata">

**Author:** ![E1andri1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E1andri1](https://forums.unrealengine.com/u/E1andri1)\
**Post date:** [September 10, 2018, 11:04am UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/2 "2018-09-10T11:04:03Z")

</div>

Turns out, get duration returns the actual duration, when the player is set to playing (and only playing. It’s not working, if it’s set on pause)

That said, it affects seek as well (I only can seek, when the player is set to play - which causes a lot of inconsistency)

The OnSeekCompleted-Event is never being called either. The video is starting to play from the desired position, though.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![DaveScenegraph](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davescenegraph/32/477797_2.png) [@DaveScenegraph](https://forums.unrealengine.com/u/DaveScenegraph)\
**Post date:** [June 24, 2019, 2:51pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/3 "2019-06-24T14:51:19Z")

</div>

Hi - I figured out a way. If you put a delay after calling play on the media source, it now returns the length. This is not the best way to do this - but its working. Any one know a better way then please leave a comment. Thanks

 ![280620-unreal-delay-timer.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/f/94f0fe2acdf9ab0e644eb3bc735dc0bad8c6e112.png)

---

<div class="post-metadata">

**Author:** ![E1andri1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E1andri1](https://forums.unrealengine.com/u/E1andri1)\
**Post date:** [June 24, 2019, 3:18pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/4 "2019-06-24T15:18:53Z")

</div>

You could actually skip the delay. See my comment above

---

<div class="post-metadata">

**Author:** ![UnrealHorrorDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealHorrorDev](https://forums.unrealengine.com/u/UnrealHorrorDev)\
**Post date:** [October 29, 2020, 11:38am UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/5 "2020-10-29T11:38:45Z")

</div>

what do you mean you can skip the delay? its not possible. You can only skip the delay if the media is already playing. If its not playing you need the delay

---

<div class="post-metadata">

**Author:** ![E1andri1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E1andri1](https://forums.unrealengine.com/u/E1andri1)\
**Post date:** [October 29, 2020, 12:04pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/6 "2020-10-29T12:04:32Z")

</div>

Back when I tested it, it was sufficient to set the state to “playing” and the duration was immediately available when I tested it.

However, with or without delay, it was entirely insufficient for my purpose back then, which is why I replaced everything with the bing player plugin, that actually worked.

---

<div class="post-metadata">

**Author:** ![Digichan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Digichan](https://forums.unrealengine.com/u/Digichan)\
**Post date:** [April 28, 2023, 8:36pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/7 "2023-04-28T20:36:10Z")

</div>

Any new info on this? Have searched around and this is the only thing I can find on this subject. Unable to get ‘Get Duration’ to return anything other than 0.  
I’m playing random sources from a playlist and using MI Interpolation to add effects at the beginning and end of the clips. Need the duration of the clip to set when to play the end effects.

---

<div class="post-metadata">

**Author:** ![HISPlayerUnreal](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hisplayerunreal/32/712778_2.png) [@HISPlayerUnreal](https://forums.unrealengine.com/u/HISPlayerUnreal)\
**Post date:** [July 4, 2023, 12:56pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/8 "2023-07-04T12:56:56Z")

</div>

With [HISPlayer](https://forums.unrealengine.com/t/hisplayer-http-live-streaming-hls-and-mpeg-dash-video-streaming-plugin-for-unreal-engine-games-and-metaverse/1135877) Unreal Engine Media Player for Windows you can get total time of a video. However, the video content must be in mp4, HLS or DASH streaming formats

---

<div class="post-metadata">

**Author:** ![DmeenaDM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DmeenaDM](https://forums.unrealengine.com/u/DmeenaDM)\
**Post date:** [April 14, 2024, 9:54am UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/9 "2024-04-14T09:54:17Z")

</div>

Well for anyone in future who is getting the duration 0, Instead of setting a hardcoded delay you can use the `On Media Opened` Delegate and bind and event to it, in that event if you try to get the duration you will get a valid value.

---

<div class="post-metadata">

**Author:** ![kim\_nancy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kim_nancy/32/876282_2.png) [@kim\_nancy](https://forums.unrealengine.com/u/kim_nancy)\
**Post date:** [April 15, 2024, 5:41am UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/10 "2024-04-15T05:41:32Z")

</div>

> [@E1andri1](#):
>
> Hello,
> 
> I’m trying to get the overall duration of a video file in a media player, because I want to rewind it at half time and restart it from the beginning.
> 
> I tried to use a reset function called by a timer that fires every 0.5 \* duration seconds. Here’s the blueprint:
> 
> [Blueprint Pastebin](https://blueprintue.com/blueprint/gufgm6f0/)
> 
> However, it doesn’t work, because the Get Duration Node returns a solid 0 no matter what file I specify. I also switched between Media Players (VLC and the Native windows media player) all with same result.
> 
> What am I doing wrong?
> 
> Kind regards and thank you

It seems the media player is struggling to fetch the duration of the video file, possibly due to compatibility issues or missing metadata. Have you checked if the file contains valid duration information in its metadata? Sometimes, specific video formats or codecs may pose challenges with duration retrieval. Exploring alternative methods or seeking advice from the community, like [Gil Birmingham Eyes](https://wealthystars.net/gil-birmingham-eyes/), might help resolve this issue.

---

<div class="post-metadata">

**Author:** ![JRFernandes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JRFernandes](https://forums.unrealengine.com/u/JRFernandes)\
**Post date:** [December 21, 2024, 11:50pm UTC](https://forums.unrealengine.com/t/media-player-get-duration-returns-0/433163/11 "2024-12-21T23:50:17Z")

</div>

One way to not use Delay is to use Open Source Latent instead of Play or Open Source, as it will only complete the execution stream when the video is open.

 ![Open Souce](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/c/7acd5462b583982f9b814bebed2f8036c5fe58c0.png)
