Skip to main content

Microsoft Silverlight

Answered Question Possible to tell MediaElement to only play a range of an MP3?RSS Feed

(0)

jemiller
jemiller

Member

Member

445 points

237 Posts

Possible to tell MediaElement to only play a range of an MP3?

Hi all,

MediaElement has a Position property which allows you to start playing at a specific position in a media file. I'm wondering there is a way to tell it to stop playing at a specific position? i.e. say I have a 3 minute MP3 file. I want to tell it to play starting at 1:55 and stop at 2:15. I'm thinking maybe I could use a timer to stop the playback, but, that seems imprecise.  

Jon

 

neopocott
neopocott

Member

Member

368 points

82 Posts

Answered Question

Re: Possible to tell MediaElement to only play a range of an MP3?

Hi,

You could add a Marker on the MP3 file at the time position that is interesting for you. In the MarkerReached event, just call the Stop() function to end the playback.

Julien Frelat
Microsoft Client App Dev MVP
Quake in Silverlight - Twitter - Blog (French)

jemiller
jemiller

Member

Member

445 points

237 Posts

Re: Possible to tell MediaElement to only play a range of an MP3?

Cool, thanks. I was wondering if the Markers collection might be able to be used for something like that. I'll give it a try.

neopocott
neopocott

Member

Member

368 points

82 Posts

Re: Possible to tell MediaElement to only play a range of an MP3?

Yes, I guess Markers were actually designed for that kind of scenarios. Smile

Do not forget to mark my reply as the answer if it helps you.

Julien Frelat
Microsoft Client App Dev MVP
Quake in Silverlight - Twitter - Blog (French)
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities