3

I have created a custom webpart to show list of video files in asp:gridview from asset library and play on the same page using Silverlight Media Player, below is code of gridview design -

<asp:GridView ID="grdProcessResults" runat="server" AutoGenerateColumns="false" Width="100%"
                            AllowPaging="True" PageSize="3" ShowHeader="false" 
                            onrowdatabound="grdProcessResults_RowDataBound" 
                            onpageindexchanging="grdProcessResults_PageIndexChanging">
                            <PagerSettings Mode="NextPrevious" NextPageImageUrl="/Style%20Library/ValueEXL/images/right.png" PreviousPageImageUrl="/Style%20Library/ValueEXL/images/left.png" PageButtonCount="3"/>  
                         <PagerStyle CssClass="sliderRightSide"  />
                            <Columns>
                                <asp:TemplateField ShowHeader="false">
                                    <ItemTemplate>
                                        <div class="searchResultRepeat">
                                            <div class="resultSubHeader frameWorkvideoPlayBox" id="mediaplayer">
                                                <asp:LinkButton ID="lbShowProcess" runat="server"><%# DataBinder.Eval(Container.DataItem, "LinkFilename")%></asp:LinkButton>
                                                <asp:HyperLink ID="ShowDemo" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Url")%>' runat="server"><%# DataBinder.Eval(Container.DataItem, "LinkFilename")%></asp:HyperLink>
                                                <%--<asp:LinkButton ID="ShowDemo" PostBackUrl='<%# DataBinder.Eval(Container.DataItem, "Url")%>' runat="server"><%# DataBinder.Eval(Container.DataItem, "LinkFilename")%></asp:LinkButton>--%>


                                            </div>
                                            <div class="searchTxt">
                                                <%# DataBinder.Eval(Container.DataItem,"SearchText") %></div>
                                            <div class="searchTag">
                                                <asp:Label ID="lblDocType" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"DocType") %>'></asp:Label>  </div>
                                        </div>
                                        <div>
                                            <object height="1" width="1" id="Silverlight_Shared_MediaPlayer" data="data:application/x-silverlight,"
                                                type="application/x-silverlight">
                                                <param value="#80808080" name="background">
                                                <param value="true" name="enableHtmlAccess">
                                                <param value="http://vdtc3-d003-fdev:2424/_layouts/clientbin/mediaplayer.xap" name="source">
                                                <param value="isOverlayPlayer=true" name="initParams">
                                                <param value="true" name="windowless">
                                            </object>
                                        </div>
                                        <script type="text/javascript" src="http://vdtc3-d003-fdev:2424/_layouts/MediaPlayer.js"></script>
                                        <script type="text/javascript">
                                            mediaPlayer.attachToMediaLinks(document.getElementById('mediaplayer'), ['wmv', 'avi', 'mp3']);  
                                        </script>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>

Problem: When there is only 1 video file in grid then it is working properly but when there are multiple files then only first video is playing in silverlight media player, rest are asking to download when clicked

Please help to resolve this issue.

2

I was having the same problem. I found a simple solution - here is an example for three videos, each with a unique DIV ID (because ID's should always be unique).

<script type="text/javascript">
        mediaPlayer.attachToMediaLinks
                (
                        (document.getElementById('vidDiv0')),
                        ['wmv', 'avi', 'mp3']
                );
        mediaPlayer.attachToMediaLinks
                (
                        (document.getElementById('vidDiv1')),
                        ['wmv', 'avi', 'mp3']
                );
        mediaPlayer.attachToMediaLinks
                (
                        (document.getElementById('vidDiv2')),
                        ['wmv', 'avi', 'mp3']
                );
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.