33// found in the LICENSE file.
44
55import type * as Common from '../../core/common/common.js' ;
6+ import * as i18n from '../../core/i18n/i18n.js' ;
7+ import type * as Platform from '../../core/platform/platform.js' ;
68import * as SDK from '../../core/sdk/sdk.js' ;
79import type * as Protocol from '../../generated/protocol.js' ;
810import * as UI from '../../ui/legacy/legacy.js' ;
@@ -11,6 +13,34 @@ import {Events, MediaModel, type PlayerEvent} from './MediaModel.js';
1113import { PlayerDetailView } from './PlayerDetailView.js' ;
1214import { PlayerListView } from './PlayerListView.js' ;
1315
16+ const UIStrings = {
17+ /**
18+ *@description Text to show if no media player has been selected
19+ * A media player can be an audio and video source of a page.
20+ */
21+ noPlayerDetailsSelected : 'No media player selected' ,
22+ /**
23+ *@description Text to instruct the user on how to view media player details
24+ * A media player can be an audio and video source of a page.
25+ */
26+ selectToViewDetails : 'Select a media player to inspect its details.' ,
27+ /**
28+ *@description Text to show if no player can be shown
29+ * A media player can be an audio and video source of a page.
30+ */
31+ noMediaPlayer : 'No media player' ,
32+ /**
33+ *@description Text to explain this panel
34+ * A media player can be an audio and video source of a page.
35+ */
36+ mediaPlayerDescription : 'On this page you can view and export media player details.' ,
37+ } ;
38+ const str_ = i18n . i18n . registerUIStrings ( 'panels/media/MainView.ts' , UIStrings ) ;
39+ const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
40+
41+ const MEDIA_PLAYER_EXPLANATION_URL =
42+ 'https://developer.chrome.com/docs/devtools/media-panel#hide-show' as Platform . DevToolsPath . UrlString ;
43+
1444export interface TriggerHandler {
1545 onProperty ( property : Protocol . Media . PlayerProperty ) : void ;
1646 onError ( error : Protocol . Media . PlayerError ) : void ;
@@ -135,6 +165,8 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
135165 private readonly downloadStore : PlayerDataDownloadManager ;
136166 private readonly sidebar : PlayerListView ;
137167
168+ #placeholder: UI . EmptyWidget . EmptyWidget ;
169+
138170 constructor ( downloadStore : PlayerDataDownloadManager = new PlayerDataDownloadManager ( ) ) {
139171 super ( 'media' ) ;
140172 this . detailPanels = new Map ( ) ;
@@ -146,6 +178,11 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
146178 this . sidebar = new PlayerListView ( this ) ;
147179 this . sidebar . show ( this . panelSidebarElement ( ) ) ;
148180
181+ this . #placeholder =
182+ new UI . EmptyWidget . EmptyWidget ( i18nString ( UIStrings . noMediaPlayer ) , UIStrings . mediaPlayerDescription ) ;
183+ this . #placeholder. show ( this . mainElement ( ) ) ;
184+ this . #placeholder. appendLink ( MEDIA_PLAYER_EXPLANATION_URL ) ;
185+
149186 SDK . TargetManager . TargetManager . instance ( ) . observeModels ( MediaModel , this , { scoped : true } ) ;
150187 }
151188
@@ -204,6 +241,11 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
204241 this . sidebar . addMediaElementItem ( playerID ) ;
205242 this . detailPanels . set ( playerID , new PlayerDetailView ( ) ) ;
206243 this . downloadStore . addPlayer ( playerID ) ;
244+
245+ if ( this . detailPanels . size === 1 ) {
246+ this . #placeholder. header = i18nString ( UIStrings . noPlayerDetailsSelected ) ;
247+ this . #placeholder. text = i18nString ( UIStrings . selectToViewDetails ) ;
248+ }
207249 }
208250
209251 private propertiesChanged ( event : Common . EventTarget . EventTargetEvent < Protocol . Media . PlayerPropertiesChangedEvent > ) :
@@ -286,6 +328,10 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
286328 this . detailPanels . delete ( playerID ) ;
287329 this . sidebar . deletePlayer ( playerID ) ;
288330 this . downloadStore . deletePlayer ( playerID ) ;
331+ if ( this . detailPanels . size === 0 ) {
332+ this . #placeholder. header = i18nString ( UIStrings . noMediaPlayer ) ;
333+ this . #placeholder. text = i18nString ( UIStrings . mediaPlayerDescription ) ;
334+ }
289335 }
290336
291337 markOtherPlayersForDeletion ( playerID : string ) : void {
0 commit comments