Thumbnail image of Silverlight video

假装没事ソ 提交于 2019-12-19 04:54:05

问题


For the popular video player, like sl2videoplayer, http://www.codeplex.com/sl2videoplayer, my question is how is the thumbnail image of Siverlight video is displayed before we click play (in the scenario of non-autoplay).

thanks in advance, George


回答1:


the MediaElement that the Video Player uses will show a thumbnail image of the frame at the current position. Otherwise, tools like Expression Encoder create thumbnail images (JPEGs or PNGs) that will be used for the video thumbnails and chapter markers.

This will show the first frame of the Bear.wmv video and won't play automatically:

<Grid x:Name="LayoutRoot" Background="White">
    <MediaElement AutoPlay="False" Source="Bear.wmv"/>
</Grid>

If you knew the time that the thumbnail comes from, you could have a secondary MediaElement with its Current Position having that time. When playback starts, you would collapse its visiblity.

Michael




回答2:


I agree that the above answer works, but it might not be optimal for every scenario. An alternate to this would be to have a specific image control that overlays the mediaElement and have it's visibility bound to an "IsPlaying" property. You would need to create the "IsPlaying" property.

Something like this:

<Grid x:Name="LayoutRoot" Background="White">
        <MediaElement AutoPlay="False" Source="Bear.wmv"/>
        <Image Source="Thumbnail" Visibility="{Binding Path=IsPlaying, Converter={StaticResource BooleanToVisibilityConverter}} />
</Grid>

Just an alternative solution. They both seem like hacks a little, but that's the fun part of what we do!



来源:https://stackoverflow.com/questions/1033331/thumbnail-image-of-silverlight-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!