This is a migrated thread and some comments may be shown as answers.

YouTube sound continues after closing

2 Answers 89 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 2
Rob asked on 16 Jan 2014, 03:28 AM
Hi,
I am using a RadWindow to display the RadMediaPlayer. It all works fine until I close the RadWindow; the sound track from the YouTube clip keeps playing. How can I stop the YouTube clip completely when the RadWindow is closed?
Thanks
Rob

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2014, 05:49 AM
Hi Rob,

Please try the following code snippet to achieve your scenario.

ASPX:
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientBeforeClose="OnClientBeforeClose">
    <ContentTemplate>
        <telerik:RadMediaPlayer ID="RadMediaPlayer1" runat="server" HDActive="false" Width="700px"
            Height="500px" StartVolume="90" Source="http://www.youtube.com/watch?v=3FcCUXrR1-0">
        </telerik:RadMediaPlayer>
    </ContentTemplate>
</telerik:RadWindow>

JavaScript:
<script type="text/javascript">
    function OnClientBeforeClose(sender, args) {
        var mediaplayer = $find("<%=RadMediaPlayer1.ClientID %>");
        mediaplayer.stop();
    }
</script>

Thanks,
Shinu.
0
Rob
Top achievements
Rank 2
answered on 16 Jan 2014, 07:36 PM
Thanks, all working now. I had to make so small changes to allow the RadWindow to include external code i.e.
From the initiating program:
<script type="text/javascript">
 
            function ShowYouTube(url) {
                        window.radopen(url, "YouTubeRadWindow");
                        return false;
            }
    function OnClientBeforeClose(sender, args) {
        var oWnd = GetRadWindowManager().getWindowByName("YouTubeRadWindow");
        oWnd.get_contentFrame().contentWindow.CloseYouTube();                       
    }
 
</script>

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="True"
                Animation="Fade" VisibleStatusbar="False" Behaviors="Close, Move" Skin="Default"
                ShowContentDuringLoad="False" KeepInScreenBounds="True">
     <Windows>
          <telerik:RadWindow ID="YouTubeRadWindow" runat="server" Width="670px" OnClientBeforeClose="OnClientBeforeClose"
                       Height="435px"  ShowContentDuringLoad="False" />
     </Windows>
</telerik:RadWindowManager>

Then this was in the called URL:

<script type="text/javascript">
           function GetRadWindow() {
               var oWindow = null;
               if (window.radWindow) {
                   oWindow = window.radWindow;
               }
               else if (window.frameElement.radWindow) {
                   oWindow = window.frameElement.radWindow;
               }
               return oWindow;
           }
 
           function CloseDialog() {
               GetRadWindow().Close();
           }
 
           function CloseYouTube() {
               var mediaplayer = $find("<%=YouTubeMediaPlayer.ClientID %>");
               mediaplayer.stop();               
           }
 
       </script>
    
   <div>
       <telerik:RadMediaPlayer ID="YouTubeMediaPlayer" runat="server" Width="640px" Height="360px"
           HDActive="false" />
   </div>

Thanks again for the quick response.
Cheers
Tags
MediaPlayer
Asked by
Rob
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Rob
Top achievements
Rank 2
Share this question
or