@@ -57,14 +57,14 @@ namespace winrt::TerminalApp::implementation
57
57
// Clear out our media player callbacks, and stop any playing media. This
58
58
// will prevent the callback from being triggered after we've closed, and
59
59
// also make sure that our sound stops when we're closed.
60
- _mediaEndedRevoker.revoke ();
61
60
if (_bellPlayer)
62
61
{
63
62
_bellPlayer.Pause ();
64
63
_bellPlayer.Source (nullptr );
65
64
_bellPlayer.Close ();
65
+ _bellPlayer = nullptr ;
66
+ _bellPlayerCreated = false ;
66
67
}
67
- _bellPlayer = nullptr ;
68
68
}
69
69
70
70
// Method Description:
@@ -168,19 +168,15 @@ namespace winrt::TerminalApp::implementation
168
168
co_await wil::resume_foreground (_control.Dispatcher ());
169
169
if (auto pane{ weakThis.get () })
170
170
{
171
- // BODGY
172
- // GH#12258: We learned that if you leave the MediaPlayer open, and
173
- // press the media keys (like play/pause), then the OS will _replay the
174
- // bell_. So we have to re-create the MediaPlayer each time we want to
175
- // play the bell, to make sure a subsequent play doesn't come through
176
- // and reactivate the old one.
177
-
178
- if (!_bellPlayer)
171
+ if (!_bellPlayerCreated)
179
172
{
180
173
// The MediaPlayer might not exist on Windows N SKU.
181
174
try
182
175
{
176
+ _bellPlayerCreated = true ;
183
177
_bellPlayer = winrt::Windows::Media::Playback::MediaPlayer ();
178
+ // GH#12258: The media keys (like play/pause) should have no effect on our bell sound.
179
+ _bellPlayer.CommandManager ().IsEnabled (false );
184
180
}
185
181
CATCH_LOG ();
186
182
}
@@ -190,27 +186,6 @@ namespace winrt::TerminalApp::implementation
190
186
const auto item{ winrt::Windows::Media::Playback::MediaPlaybackItem (source) };
191
187
_bellPlayer.Source (item);
192
188
_bellPlayer.Play ();
193
-
194
- // This lambda will clean up the bell player when we're done with it.
195
- auto weakThis2{ get_weak () };
196
- _mediaEndedRevoker = _bellPlayer.MediaEnded (winrt::auto_revoke, [weakThis2](auto &&, auto &&) {
197
- if (auto self{ weakThis2.get () })
198
- {
199
- if (self->_bellPlayer )
200
- {
201
- // We need to make sure clear out the current track
202
- // that's being played, again, so that the system can't
203
- // come through and replay it. In testing, we needed to
204
- // do this, closing the MediaPlayer alone wasn't good
205
- // enough.
206
- self->_bellPlayer .Pause ();
207
- self->_bellPlayer .Source (nullptr );
208
- self->_bellPlayer .Close ();
209
- }
210
- self->_mediaEndedRevoker .revoke ();
211
- self->_bellPlayer = nullptr ;
212
- }
213
- });
214
189
}
215
190
}
216
191
}
@@ -223,7 +198,7 @@ namespace winrt::TerminalApp::implementation
223
198
void TerminalPaneContent::_RestartTerminalRequestedHandler (const winrt::Windows::Foundation::IInspectable& /* sender*/ ,
224
199
const winrt::Windows::Foundation::IInspectable& /* args*/ )
225
200
{
226
- _RestartTerminalRequestedHandlers (*this , nullptr );
201
+ RestartTerminalRequested. raise (*this , nullptr );
227
202
}
228
203
229
204
void TerminalPaneContent::UpdateSettings (const TerminalSettingsCreateResult& settings,
@@ -232,4 +207,13 @@ namespace winrt::TerminalApp::implementation
232
207
_profile = profile;
233
208
_control.UpdateControlSettings (settings.DefaultSettings (), settings.UnfocusedSettings ());
234
209
}
210
+
211
+ // Method Description:
212
+ // - Should be called when this pane is created via a default terminal handoff
213
+ // - Finalizes our configuration given the information that we have been
214
+ // created via default handoff
215
+ void TerminalPaneContent::MarkAsDefterm ()
216
+ {
217
+ _isDefTermSession = true ;
218
+ }
235
219
}
0 commit comments