# Bookmark (persist) time position of played files

**URL:** <https://discourse.mopidy.com/t/bookmark-persist-time-position-of-played-files/3452>\
**Category:** Misc\
**Created:** [September 3, 2019, 8:55am UTC](https://discourse.mopidy.com/t/bookmark-persist-time-position-of-played-files/3452 "2019-09-03T08:55:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![csibug](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/csibug/32/1488_2.png) [@csibug](https://discourse.mopidy.com/u/csibug)\
**Post date:** [September 3, 2019, 8:55am UTC](https://discourse.mopidy.com/t/bookmark-persist-time-position-of-played-files/3452/1 "2019-09-03T08:55:27Z")

</div>

i would like to implement a feature that can save the current time position of a played file on cancel or stop.  
i’ve checked the available events, but it seems to me that the track\_playback\_ended didn’t fire on cancel or stop, it is fired at the end of the file.  
the playback\_state\_changed event is available, but it doesn’t contain the time position.

any advice is welcomed.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 3, 2019, 9:25am UTC](https://discourse.mopidy.com/t/bookmark-persist-time-position-of-played-files/3452/2 "2019-09-03T09:25:00Z")

</div>

There’s [https://docs.mopidy.com/en/latest/api/core/#mopidy.core.CoreListener.track\_playback\_paused](https://docs.mopidy.com/en/latest/api/core/#mopidy.core.CoreListener.track_playback_paused) for pausing but when you issue a stop command you do actually stop, which involves resetting the playback position to 0 (and releasing the audio device etc).

Alternatively you can query for the current position after you receive a `playback_state_changed` event. But you’ll hit the same problem that if it was a `stop` then the returned position will be 0.

I don’t think we have anything in our API that will tell you the time _before_ stopping.

---

<div class="post-metadata">

**Author:** ![csibug](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/csibug/32/1488_2.png) [@csibug](https://discourse.mopidy.com/u/csibug)\
**Post date:** [September 6, 2019, 3:32am UTC](https://discourse.mopidy.com/t/bookmark-persist-time-position-of-played-files/3452/3 "2019-09-06T03:32:45Z")

</div>

thank you for the answer, i think the track\_playback\_paused is a great idea, and it might work for me. thank you again!
