AppNotificationBuilder.SetAudioUri 方法

定義

多載

SetAudioUri(Uri)

設定顯示代理程式更新時播放的音效檔案。

SetAudioUri(Uri, AppNotificationAudioLooping)

設定顯示代理程式更新時播放的音效檔案和音訊迴圈行為。

SetAudioUri(Uri)

設定顯示代理程式更新時播放的音效檔案。

public:
 virtual AppNotificationBuilder ^ SetAudioUri(Uri ^ audioUri) = SetAudioUri;
/// [Windows.Foundation.Metadata.Overload("SetAudioUri")]
AppNotificationBuilder SetAudioUri(Uri const& audioUri);
[Windows.Foundation.Metadata.Overload("SetAudioUri")]
public AppNotificationBuilder SetAudioUri(System.Uri audioUri);
function setAudioUri(audioUri)
Public Function SetAudioUri (audioUri As Uri) As AppNotificationBuilder

參數

audioUri
Uri Uri

音訊檔案的 URI。

傳回

傳回 AppNotificationBuilder 實例,以便鏈結其他方法呼叫。

屬性

範例

下列範例示範如何在代理程式更新的 XML 承載中設定音訊 URI。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetAudioUri(new Uri("ms-appx:///Audio/NotificationSound.mp3"))
    .BuildNotification();


AppNotificationManager.Default.Show(notification);

產生的 XML 承載:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <audio src='ms-appx:///Audio/NotificationSound.mp3'/>
</toast>

備註

支援下列音訊檔案類型:

  • .aac
  • .flac
  • .m4a
  • .mp3
  • .wav
  • .wma

支援下列音訊檔案來源:

  • ms-appx:///
  • ms-resource

不支援下列音訊檔案來源:

  • ms-appdata
  • 網際網路 URL,例如 HTTP://、HTTPs://
  • 絕對檔案路徑,例如 C:/、F:/等。

您可以藉由呼叫 SetAudioEvent來指定播放系統定義音效的音效事件。

如需使用 AppNotificationBuilder API 建立代理程式更新 UI 的指引,請參閱 代理程式更新內容

如需代理程式更新之 XML 架構的參考資訊,請參閱 代理程式更新內容架構

適用於

SetAudioUri(Uri, AppNotificationAudioLooping)

設定顯示代理程式更新時播放的音效檔案和音訊迴圈行為。

public:
 virtual AppNotificationBuilder ^ SetAudioUri(Uri ^ audioUri, AppNotificationAudioLooping loop) = SetAudioUri;
/// [Windows.Foundation.Metadata.Overload("SetAudioUri2")]
AppNotificationBuilder SetAudioUri(Uri const& audioUri, AppNotificationAudioLooping const& loop);
[Windows.Foundation.Metadata.Overload("SetAudioUri2")]
public AppNotificationBuilder SetAudioUri(System.Uri audioUri, AppNotificationAudioLooping loop);
function setAudioUri(audioUri, loop)
Public Function SetAudioUri (audioUri As Uri, loop As AppNotificationAudioLooping) As AppNotificationBuilder

參數

audioUri
Uri Uri

音訊檔案的 URI。

loop
AppNotificationAudioLooping

AppNotificationAudioLooping列舉的成員,指定音訊的迴圈行為。

傳回

傳回 AppNotificationBuilder 實例,以便鏈結其他方法呼叫。

屬性

範例

下列範例示範如何在代理程式更新的 XML 承載中設定音訊 URI。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetAudioUri(new Uri("ms-appx:///Audio/NotificationSound.mp3"), AppNotificationAudioLooping.Loop)
    .BuildNotification();


AppNotificationManager.Default.Show(notification);

產生的 XML 承載:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <audio src='ms-appx:///Audio/NotificationSound.mp3'/>
</toast>

備註

支援下列音訊檔案類型:

  • .aac
  • .flac
  • .m4a
  • .mp3
  • .wav
  • .wma

支援下列音訊檔案來源:

  • ms-appx:///
  • ms-resource

不支援下列音訊檔案來源:

  • ms-appdata
  • 網際網路 URL,例如 HTTP://、HTTPs://
  • 絕對檔案路徑,例如 C:/、F:/等。

您可以藉由呼叫 SetAudioEvent來指定播放系統定義音效的音效事件。

如需使用 AppNotificationBuilder API 建立代理程式更新 UI 的指引,請參閱 代理程式更新內容

如需代理程式更新之 XML 架構的參考資訊,請參閱 代理程式更新內容架構

適用於