Mediaplayer issues

Posted by: tomgiam on 7 August 2017, 6:59 am EST

  • Posted 7 August 2017, 6:59 am EST

    I use a mediaplayer to autoplay a video using this code:

    C1MediaItem mi = new C1MediaItem();

    mi.MediaSource = new Uri(filename, UriKind.RelativeOrAbsolute);

    mediaPlayer.AutoPlay = true;mediaPlayer.IsLooping = true;

    mediaPlayer.Items.Clear();

    mediaPlayer.Items.Add(mi);

    The graphic shows that it's playing (displaying pause), but video does not play (shows first frame) until unpaused and play is clicked again

    If I add this it helps, but not allways for all videos:

    Thread thread1 = new Thread(new ThreadStart(() =>

    {

    Thread.Sleep(3000);

    mediaPlayer.Dispatcher.BeginInvoke(() => mediaPlayer.Play());

    }));

    thread1.Start();

    Maybe adding a MediaIsLoaded event could help?

    Another general problem is that the circle can sometimes spin a very long time, and it seems that if I click on the interface (play/pause or circle), I can make it stop spinning and be able to interact with the video.

    Thanks

    Tom

  • Posted 7 August 2017, 6:59 am EST

    Thanks for looking into this.

    It's Silverlight. I use it in different ways, but one way is within a C1Window and in response to clicking on the video listed in a C1TreeView.

    The C1MediaItem is created after each click.

    It's initially empty, but then after selecting the first video it has that video until you select another video from the C1TreeView.

    A URL you can use is:

    http://liquidalbums.com/Art/Standard/Video/waterweb.wmv

    Maybe it's the encoding?

    Thanks

    Tom

  • Posted 7 August 2017, 6:59 am EST

    I think that particular file is somehow corrupted. I can play it with Silverlight and Windows Media Player under Windows 7, but the version of Media Player Classic included in the latest klite codec pack chokes on the file.

    C1MediaPlayer inherits a limitation from Silverlight's MediaElement. Playing is interrupted when the control is taken off the visual tree, even if it's immediately re parented. This complicates full screen, for example. Make sure to Show() the C1Window container before you set the MediaItem. Otherwise, the MediaElement inside C1MediaPlayer will ignore the play request.

    Regards,

    Bruno

  • Posted 7 August 2017, 6:59 am EST

    I re-encoded the file with Microsoft Expression Encoder 3 and it seems to be better.

    I don't take anything off of the visual tree (I just get the video file name from the tree node) and I do a ShowModal() so the second part should not effect me.

    Thanks

    Tom

  • Posted 7 August 2017, 6:59 am EST

    Good to hear it's better.

    It is not you who removes the C1MediaPlayer from the visual tree, but C1Window. Anyway, if it's working for you now, this wasn't the case.

    Have a happy new year, Tom!

    Bruno

  • Posted 7 August 2017, 6:59 am EST

    Hi, Tom.

    I'm unable to reproduce this bug. When do you create the C1MediaItem? In an event handler? Was the C1MediaPlayer empty? Is this WPF or Silverlight? Does the same video always give you trouble? Can you share the video file URL?

    Regards,

    Bruno

  • Posted 7 August 2017, 6:59 am EST

    Bruno,

    Just wanted to let you know that I re-encoded all of my videos and they all work much better.

    I appreciate your help

    Happy new year

    Tom

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels