Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Silverlight
I have a media element which I give a source I get from Microsofts translation service. This is a slight problem because it gives me a wav file. I used the WAVmss library to help me and it works great, but for one thing. It plays the first time I load the file into the element, but when I try and play it a second time it doesn't play? The playback code could not be simpler:
 
private void Play()
        {
            mediaElement.Stop();
            mediaElement.Position = TimeSpan.Zero;
            mediaElement.Play();
        }
 
I have debugged. The Position property does get set to zero, ,and when I break in after clicking it again its position has moved to the end.
 
An ideas?
Posted 1-Aug-11 0:03am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try:
if (mediaElement.CurrentState == MediaElementState.Playing)
                {
                    mediaElement.Pause();
                }
                else
                {
                    if (mediaElement.CurrentState == MediaElementState.Paused)
                    {
                        if (mediaElement.Position == mediaElement.NaturalDuration.TimeSpan)
                        {
                            mediaElement.Position = new TimeSpan(0);
                        }
                        mediaElement.Play();
                    }
                 }
  Permalink  
Comments
dominic_nologo at 1-Aug-11 7:22am
   
Thanks random person! But I am still having the same problem. Your code is not that much different to mine...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I had the same issue and thanks to Gilles Khouzam quick response the problem has been solved.
 
"Ok, I found the issue. The implementation of SeekAsync, the position in the stream was changed but the remaining count in the chunk was not. In WaveMediaStreamSource.cs, look for the SeekAsync method and change the code to this (add the MoveToChunkOffest line):"
 
this.currentPosition = this.wavParser.WaveFormatEx.BufferSizeFromAudioDuration( seekToTime ) + this.startPosition;
this.wavParser.MoveToChunkOffset( ( uint ) this.wavParser.WaveFormatEx.BufferSizeFromAudioDuration( seekToTime ) );
this.currentTimeStamp = seekToTime;
ReportSeekCompleted( seekToTime );
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Zoltán Zörgő 330
1 Sergey Alexandrovich Kryukov 230
2 Peter Leow 204
3 OriginalGriff 160
4 88388132 128
0 Sergey Alexandrovich Kryukov 8,288
1 OriginalGriff 6,396
2 Peter Leow 3,557
3 Zoltán Zörgő 3,221
4 Richard MacCutchan 2,397


Advertise | Privacy | Mobile
Web03 | 2.8.150123.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100