how to Play video files in sliverlight

2 posts, 0 answers
  1. sachin
    sachin avatar
    4 posts
    Member since:
    Aug 2011

    Posted 31 Aug 2011 Link to this post

    Hi,

    i want to play video file in media element with set source runtime from web server path.
    i am using following code :

      String strVideoName="PoreotixAmericasBest.mp4";
      Uri VideoUri = new Uri(App.Current.Host.Source, strVideoName );
      myVideo.Source = VideoUri;
      myVideo.Play();

    i am using above code, but it's not working video not play.
    If i set file name which is in "Client Bin" directory at design time then it's play.

    anybody have a solution for set video file path dynamically at runtime replay me as soon as possible.


  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Sep 2011 Link to this post

    Hello Sachin,

    Basically the RadMediItem in its core is a wrapper around the MediaElement control and as such has no access to the local file system. So in order to be able to play video files with Silverlight, you'll need to make them visible to the world (through http or Media Services...) and after that play them in the RadMediaPlayer as RadMediaItems with source like "http://mydomain.com/Videos/Video.wmv".

    Or you will have to place them in the folder containing your .xap, so that they can be requested under the same path (Source="/Video.wmv" - this relative path indicates the folder where the SL xap is located, in this case the ClientBin and this is why placing the movie in the ClientBin works). When you set the MediaItem Source to new Uri(App.Current.Host.Source, strVideoName ) - the item will look for the video file in the ClientBin as the App.Current.Host.Source holds the path to the Silverlight application XAP file and this is why your scenario only works when you place the video in the ClientBin directory..

    I hope this information will help you.

    Greetings,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft banner
Back to Top