65.9K
CodeProject 正在变化。 阅读更多。
Home

Silverlight 版本冲突的简单解决方案

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.44/5 (3投票s)

2008年10月23日

CPOL

3分钟阅读

viewsIcon

29440

downloadIcon

115

Silverlight 版本冲突的解决方案。

引言

我曾在我的 电子学校 网站中使用 Silverlight 技术。在强大的 MinoPlayersilver light 流媒体服务 的帮助下,我能够为我的学生提供视觉课程。我的网站使用了 Silverlight 2 beta 2 版本至少三个月,我的大部分学生都下载了该 beta 版本,一切运行良好!

最近,当微软发布了 Silverlight 2 的最终版本时,我面临着升级到最终版本的问题。我既不想中断我的学生升级到最新版本,又担心如果他们升级到新版本,例如当使用需要最终版本的网站时,我的网站将不再为他们提供视频课程!

MinoPlayer 的作者提供了一个与其产品最终发布的 Silverlight 2 兼容的新版本,但它无法与 Silverlight 2 beta 2 一起使用。旧版本的 MinoPlayer 无法与 Silverlight 2 的最终版本一起使用!
我也希望我的新学生能够下载并使用 Silverlight 的最终版本。

Using the Code

我一直在努力寻找一个能够处理以下场景的解决方案

  • 我的现有学生应该能够使用他们当前下载的 Silverlight(Silverlight 2 beta 2);同时,如果他们想升级到最终版本,他们应该有机会。
  • 如果我的现有学生升级到 Silverlight 的最终版本,例如当使用需要较新版本 Silverlight 的网站时,我的应用程序必须能够为他们提供服务。
  • 我的新学生应该使用最终版本,我的应用程序不应该强迫他们使用旧版本的 Silverlight。

经过一些实验,我提出了一个非常简单但高效的 Silverlight 版本冲突解决方案。
在服务器端,我放置了两个版本的 MinoPlayer。MinoPlayer_Ver1_2.xap(旧版本)并且我将新版本重命名为 MinoPlayer_Ver1_2Final.xap,并将它们放在同一个目录中。

其余的魔力在客户端实现:我提供了两个 嵌套的 Silverlight 对象。外部 对象指向 Silverlight 2 最终版本,并且源指向 版本的 MinoPlayer

<object data="data:application/x-silverlight,"
     type="application/x-silverlight-2"
          width="90%" height="330">
<param name="source" value="MinoPlayer_Ver1_2Final.xap">

此外部对象的下载提示指向微软 Silverlight 2 最终版本的位置

<a href="http://go.microsoft.com/fwlink/?LinkId=124807"
     style="text-decoration: none;">
<img src='info.PNG' 
style='width:17px; height:19px;border-style: none' align='middle'>
<span class='lazez'><strong>There is a newer version of  
<span style='color:#FF00FF'>Microsoft Silverlight</span>
...Click here if you want to install it</strong></span>
</a>

内部 对象指向 Silverlight 2 beta 2,源指向 旧版本 的 MinoPlayer

<object data="data:application/x-silverlight," 
type="application/x-silverlight-2-b2"
                      width="90%" height="330">
<param name="source" 
value="MinoPlayer_Ver1_2.xap">

内部 对象的下载提示 指向微软 Silverlight 2 最终版本的位置

<a href="http://go.microsoft.com/fwlink/?LinkId=124807" 
    style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181"
 alt="Click here to install Silverlight"  style="border-style: none">
</a>

这是该想法的完整 HTML 代码

<div align="center">
<!-- outer silverlight object-->
<object data="data:application/x-silverlight," 
type="application/x-silverlight-2"  
width="90%" height="330">
<param name="source" 
value="MinoPlayer_Ver1_2Final.xap">
<param name="onerror" value="onSilverlightError">
<param name="background" value="black">
<param name="initParams" 
value="VideoSource=http://silverlight.services.live.com/77137/Arabic4/video.wmv
,AutoPlay=false,EnableScrubbing=true,InitialVolume=1
,PreviewImage=http://www.eschoolsudan.com/images/PreviewImage.JPG
,LogoImage=http://www.eschoolsudan.com/images/logosmall.JPG,MarkersTimeView=5">
<div class='worningpanel' align="left">
<a href="http://go.microsoft.com/fwlink/?LinkId=124807" 
style="text-decoration: none;">
<img src='info.PNG' 
style='width:17px; height:19px;border-style: none' align='middle'><
span class='lazez'><strong>There is a newer version of  <
span style='color:#FF00FF'>Microsoft Silverlight</span>
...Click here if you want to install it</strong></span>
</a> ...
</div><br>
<div align="center">
<!-- Inner silverlight object-->
<object data="data:application/x-silverlight," 
type="application/x-silverlight-2-b2" 
 width="90%" height="330">
<param name="source" 
value="MinoPlayer_Ver1_2.xap">
<param name="onerror" value="onSilverlightError">
<param name="background" value="black">
<param name="initParams" 
value="VideoSource=http://silverlight.services.live.com/77137/Arabic4/video.wmv
,AutoPlay=false,EnableScrubbing=true
,InitialVolume=1
,PreviewImage=http://www.eschoolsudan.com/images/PreviewImage.JPG
,LogoImage=http://www.eschoolsudan.com/images/logosmall.JPG,MarkersTimeView=5">
<a href="http://go.microsoft.com/fwlink/?LinkId=124807" 
style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" 
alt="Click here to install Silverlight"  style="border-style: none">
</a>
</object>
</div>
</object>
<iframe style='visibility: hidden;
 height: 0; width: 0; border: 0px'></iframe>
</div>

工作应用程序的截图

When the old beta version of Silverlight is installed in the user machine, she will be able to view the lessons while having the chance upgrading to the final release.

当用户计算机上未安装任何 Silverlight 版本时,她将看到两个链接,告诉她安装 Silverlight;按下其中任何一个,她都能够下载最终版本。

When the old beta version of Silverlight is installed in the user machine, she will be able to view the lessons while having the chance upgrading to the final release.

当用户计算机上安装了旧的 beta 版 Silverlight 时,她将能够观看课程,同时有机会升级到最终版本。

When the old beta version of Silverlight is installed in the user machine, she will be able to view the lessons while having the chance upgrading to the final release.

当用户计算机上安装了 Silverlight 的最终版本时,她将收到课程,并且不会出现任何链接。

关注点

  • 在我的想法的实际实现中,我在服务器端提供了一个 PHP 函数,该函数构建 Silverlight 对象并将每个对象填充其所需的数据;没有冗余的公共数据。
  • 在用 FireFox 测试应用程序时,当 beta 版本是工作版本时,用户将无法看到最终版本的下载链接。虽然这不太好,但它并没有损害我的想法。
  • 我的网站和我的视频以阿拉伯语提供课程!
© . All rights reserved.