English 中文(简体)
WPF 媒体 如何从哪里恢复游戏?
原标题:WPF MediaElement how to resume playing from where it pause?

i 设有2个县,即“游戏和Pause”,在一点点点火时,音乐站和点击“游戏”从一开始便开始。 我想像在一场新闻发布会上那样做,它从我已经停止的地方恢复。

        private void PlayAudio()
    {


        McMediaElement.LoadedBehavior = MediaState.Manual;
        McMediaElement.Source = new Uri("../../SingAlong/Food Fit For A King/old king cole.mp3", UriKind.RelativeOrAbsolute);
        McMediaElement.Play();
    }

    private void button1_Click_1(object sender, RoutedEventArgs e)
    {
        PlayAudio();

    }

    private void button2_Click(object sender, RoutedEventArgs e)
    {
        McMediaElement.Pause();
    }
问题回答

http://www.un.org/Depts/DGACM/index_french.htm 这使您的反对从打电话<代码>Play(<>开始起就开始使用新装的媒体。 请不要在“手稿”上填写<代码>button1_Click_1,而只使用<代码>Play()方法:

private void button1_Click_1(object sender, RoutedEventArgs e)
{
    McMediaElement.Play();
}

这为我工作。

private void button1_Click_1(object sender, RoutedEventArgs e)
{
   McMediaElement.LoadedBehavior = MediaState.Pause;
}
private void button2_Click_1(object sender, RoutedEventArgs e)
{
   McMediaElement.LoadedBehavior = MediaState.Play;
}

很多年过去了,但可能对人有用。

这对我来说是好的:

    bool isPaused = false;
    
    // Button play
    private void button1_Click_1(object sender, RoutedEventArgs e)
    {
       if(!isPaused){
    // Do all what You want
    }
    isPaused = false;
    myMediaElement.Play();
    }
    
    // Button Pause:
    private void button2_Click_1(object sender, RoutedEventArgs e)
    {
      isPaused = true;
      myMediaElement.Pause();
    }




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签