Passing file name to windows media player on click

3 posts, 1 answers
  1. Joe
    Joe avatar
    51 posts
    Member since:
    Oct 2008

    Posted 02 Sep 2011 Link to this post

    I trying to figure out how to pass the name of a wave file that is displayed into the file explorer. So when the user double clicks on the file name, it plays in a media player that is next to the file explorer (see attached screen shot).

    Currently if you double click the file name a window opens and the wave file starts playing. That doesn't work to well as if you close the window the calls keeps playing.

    I need to pass the JavaScript var "name" to
    <param name="URL" value=""  />
    in the Windows Media Player control and not have the file explorer default to
    popping up a window and using the user's default media player.

    Any suggestions????

    Thanks,
    Joe

    Here's the code I have got so far...

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
        <br />
         <table cellspacing="4">
            <tr>
                <td rowspan="2" style="vertical-align: top;">
                    Browse to an image and click to preview.
                    <telerik:RadFileExplorer ID="RadFileExplorer1" Runat="server" Configuration-MaxUploadFileSize="104857600" Width="500px">
                        <Configuration SearchPatterns="*.*"></Configuration>
                    </telerik:RadFileExplorer>
                </td>
                <td style="vertical-align: top">
                <br />
                    <fieldset style="width: 270px; height: 85px">
                        <legend> Play Call  </legend>
                       
                      <script type="text/javascript">
                          function OnClientFileOpen(oExplorer, args) {
                              var item = args.get_item();
     
                              //check if the opened item is a file
                              //if the item does not have extension it is a directory
                              //you can add additional check if the file has specific extension
                              if (item.get_extension()) {
                                  args.set_cancel(true); //cancel the default execution
     
                                  var name = item.get_name(); //you can use get_path() method to get full path to the item
                                  alert(name);
                                   
                                  //execute the custom function changing the video in the MediaPlayer control
                              }
     
                          }
    </script>
                             
                   <object id="MediaPlayer1" height="65" 
                   classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">
                     <param name="URL" value=""  />
                        <param name="FileName" value="" />
                        <param name="enabled" value="true" />  
                        <param name="ShowStatusBar" value="-1"/>
                         <param name="AutoStart" value="-1"/>
                         <param name="BufferingTime" value="5"/>
                         <param name="ShowCaptioning" value="0"/>
                         <param name="WindowlessVideo" value="0"/>
                         <param name="Balance" value="-1"/>
                         <param name="PreviewMode" value="1"/>
                         <param name="Volume" value="100"/>
                          <param name="AudioStream" value="-1"/>
                          <param name="AutoSize" value="-1"/>
                          <param name="AnimationAtStart" value="0"/>
                          <param name="AllowScan" value="0"/>
                          <param name="AllowChangeDisplaySize" value="0"/>
                          <param name="AutoRewind" value="0"/>
                          <param name="ClickToPlay" value="-1"/>
                          <param name="CursorType" value="0"/>
                          <param name="CurrentPosition" value="-1"/>
                          <param name="CurrentMarker" value="0"/>
                          <param name="DisplayBackColor" value="0"/>
                          <param name="DisplayForeColor" value="16777215"/>
                          <param name="DisplayMode" value="0"/>
                          <param name="DisplaySize" value="0"/>
                          <param name="EnableContextMenu" value="-1"/>
                          <param name="EnablePositionControls" value="-1"/>
                          <param name="EnableFullScreenControls" value="-1"/>
                          <param name="EnableTracker" value="-1"/>
                          <param name="InvokeURLs" value="-1"/>
                          <param name="Language" value="-1"/>
                          <param name="Mute" value="0"/>
                          <param name="PlayCount" value="1"/>
                          <param name="Rate" value="1"/>
                          <param name="SelectionStart" value="0"/>
                          <param name="SelectionEnd" value="-1"/>
                          <param name="SendOpenStateChangeEvents" value="0"/>
                          <param name="SendWarningEvents" value="0"/>
                          <param name="SendErrorEvents" value="0"/>
                          <param name="SendKeyboardEvents" value="0"/>
                          <param name="SendMouseClickEvents" value="0"/>
                          <param name="SendMouseMoveEvents" value="0"/>
                          <param name="SendPlayStateChangeEvents" value="0"/>
                          <param name="ShowControls" value="-1"/>
                          <param name="ShowAudioControls" value="-1"/>
                          <param name="ShowDisplay" value="0"/>
                          <param name="ShowGotoBar" value="0"/>
                          <param name="ShowPositionControls" value="-1"/>
                          <param name="ShowTracker" value="-1"/>
                          <param name="TransparentAtStart" value="-1"/>
                          <param name="VideoBorderWidth" value="2"/>
                          <param name="VideoBorderColor" value="0"/>
                          <param name="VideoBorder3D" value="-1"/>
                    </object>
                    
    <br />
      
        </div>
     
                    </fieldset>
                </td>
            </tr>
        </table>
         
        
    </asp:Content>
  2. Answer
    Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 06 Sep 2011 Link to this post

    Hi Joe,

    Try to modify the function OnClientFileOpen as follows:
    <script type="text/javascript">
        function OnClientFileOpen(oExplorer, args) {
            var item = args.get_item();
     
            //check if the opened item is a file
            //if the item does not have extension it is a directory
            //you can add additional check if the file has specific extension
            if (item.get_extension()) {
                //cancel the default execution
     
                var path = item.get_path(); //you can use get_path() method to get full path to the item
                alert(path);
     
                var mediaPlayer = $get("MediaPlayer1");
                mediaPlayer.URL = path;
     
            }
            args.set_cancel(true);
     
        }
    </script>

    This works on my end.

    Kind regards,
    Rumen
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joe
    Joe avatar
    51 posts
    Member since:
    Oct 2008

    Posted 06 Sep 2011 Link to this post

    Thanks, that worked perfectly!

    Joe
Back to Top