Welcome to the ASP.NET Controls for Silverlight forum!

Last post 05-03-2008 6:33 PM by FoolongC. 19 replies.

Sort Posts:

  • Re: Welcome to the ASP.NET Controls for Silverlight forum!

    05-03-2008, 3:48 PM
    • Loading...
    • FoolongC
    • Joined on 08-23-2007, 9:12 PM
    • Posts 40

    I started by trying to set the source from the page load event:

    mediaPlay1.Source = "PathToMovie"; 

    The player wouldn't load to the page because the media player tag was missing an element.

    So I set it in a preInit method and got the page to display the media player but the movie wouldn't autoplay (wouldn't even load when I hit the play button).

    That's when I made this post.

    I looked up your suggestion on using an ASX file - too much work for this (i.e. - re-encoding from wmv to asf - just using the media player here as a side type thing on a personal web page that does something else. A hard coded array will work just fine :-)

    Here's my function:

    <script type="text/javascript">

    function loadNewMovie(){ alert("entered loadNewMovie");

    var sender = document.getElementById("MediaPlayer1");

    sender.MediaSource = "~/movies/Italiantime.wmv";

    }

    </script>

    The alert works so I know I'm hitting it. But ... missing something. The next movie doesn't load. On hitting play I get the original movie that's set within the media player markup.

    I did something similar to this with the ASP.NET AJAX Slidshow where I used a stand alone web service and server.mapPath and directory.getFiles to populate a string array of paths to pictures for the slideshow to display.

  • Re: Welcome to the ASP.NET Controls for Silverlight forum!

    05-03-2008, 3:57 PM

    First, 'Source' is not the right proprety to set. That's the source to the XAML skin for the player. You want to set the MediaSource property.

    Second, you have to understand on the client side you have an AJAX type to work with, you arent accessing the server-side control. Your code is doing nothing more than setting an expando on a DOM element. here is what I mean:

    function mediaEnded(sender, args) {
      sender.set_mediaSource('newmovie.wmv');
    }

    This is an event handler to the client-side media player type's mediaEnded event. Sender is the media player that raised it.

     

    End the confusion.
    Infinities Loop: TRULY Understanding ViewState
    .NET from a new perspective.

    This posting is provided "AS IS".
  • Re: Welcome to the ASP.NET Controls for Silverlight forum!

    05-03-2008, 4:35 PM
    • Loading...
    • FoolongC
    • Joined on 08-23-2007, 9:12 PM
    • Posts 40

    Hmmm ...

     I feel like I'm almost there. When the initial movie that's set with the MediaSource property in the MediaPlayer element is finished playing the media player on the page goes "blank" now - as in there's no still pic in the player. The play button doesn't load anything.  Before, a still for the original movie was displayed and pressing play reloaded the movie. Is there more or am I still doing something wrong.

    <script type="text/javascript">

    function loadNewMovie(sender, args){

    sender.set_mediaSource('~/movies/italiantime.wmv');

    }

    </script><asp:MediaPlayer ID="MediaPlayer1" runat="server" Height="250px" Width="360px"

    MediaSource = "~/movies/italiantime.wmv"

    AutoPlay="true"

    MediaSkinSource="~/Professional.xaml"

    OnClientMediaEnded="loadNewMovie">

    </asp:MediaPlayer>

  • Re: Welcome to the ASP.NET Controls for Silverlight forum!

    05-03-2008, 5:33 PM

    It's not loading the movie, because "~" not understood on the client side. That is an asp.net server-side concept that means 'the root of the application'. The client side in the browser has no clue where the root of the application is. So it is literally trying to load a movie in the "~" directory, which there is none. You need to provide a URL that is either relative to the current page (e.g. movies/foo.wmv) or absolute (e.g. /myapp/movies/foo.wmv). Or you can can use the server-side ResolveClientUrl method to convert the path from one that contains "~/" into one that doesn't.

    Also about one of your earlier comments about ASX, you don't need to reencode anything to use it. It's just a client-side playlist. You would just list each of your movies as entries in the xml. If you search on silverlight and asx support you should find plenty of examples.

    End the confusion.
    Infinities Loop: TRULY Understanding ViewState
    .NET from a new perspective.

    This posting is provided "AS IS".
  • Re: Welcome to the ASP.NET Controls for Silverlight forum!

    05-03-2008, 6:33 PM
    • Loading...
    • FoolongC
    • Joined on 08-23-2007, 9:12 PM
    • Posts 40

    Works! Thank you very much! I'll take your advice and look up the usage of an asx file.

    Thanks again!

Page 2 of 2 (20 items) < Previous 1 2