3 Replies
      Latest reply on Mar 28, 2019 8:00 AM by dreamgfx
      dreamgfx Level 1 Level 1 (0 points)

        I have page with mediaContent items that are starting on 'highlight'. With 'holdselect' I can open player to the full screen - player.present().
        How to detect when the player will be closed?

         

        When I come back to the page with the media Content items focus goes automatically to the first item and APP will play two movies at the same time. It looks terrible.

         

        Player is not part of the navigation.document and I can't see any event that I can apply to it to solve that problem.

        • Re: How to detect close of the player?
          dreamgfx Level 1 Level 1 (0 points)

          It's kind of hacky solution but it works...

          I found that function getActiveDocument() is not returning result when player is on full screen. So...

           

          function Home ( getAssetURL ) {
            const
              doc = getActiveDocument ()
            , mediaContent = doc.getElementsByTagName ( 'mediaContent' ) 
            , assetId = media.getAttribute ( 'assetId' )
            ;
          
          
            for ( let k of mediaContent.keys() ) { // MediaContent player settings
               const
                 media = mediaContent.item ( k )
               , mediaSelect = media.parentNode
               , movie = new MediaItem ( 'video', getAssetURL(assetId) )
               ;
          
              let
               player      = media.getFeature ( 'Player' )
             , timmer     = false
             , fullscreen = false
             ;
            player.playlist = new Playlist ()
          
            mediaSelect.addEventListener ( 'highlight', () => {
                     if ( !fullscreen ) player.playlist.push ( movie )
                     else fullscreen = false
                 })
          
            mediaSelect.addEventListener ( 'holdselect', () => {
                   player.present () // Expand player to full screen
                   timmer = setInterval ( () => {
                                          if ( getActiveDocument() ) {
                                                       player.stop ()
                                                       player.playlist = new Playlist ()
                                                       clearInterval ( timmer )
                                              }
                                }, 500)
                   fullscreen = true
                })
          
            mediaSelect.addEventListener ( 'play', () => { // Recognize "pause" event
                                 if ( player.playbackState == 'playing' ) player.pause ()
                                 else player.play ()
                         })
           } // for mediaContent
          } // Home func.
           
          • Re: How to detect close of the player?
            jfoo Apple Staff Apple Staff (180 points)

            This seems like a bug. Can you file a radar at https://bugreport.apple.com? Thanks!

              • Re: How to detect close of the player?
                dreamgfx Level 1 Level 1 (0 points)

                Seems more like not documented feature to me... Function name is 'getActiveDocument'. There is no active document till video player is full screen.

                 

                Anyway - "Seems like a bug" is not answering my question:  How to detect when the player will be closed?