• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# AudioTrack类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AudioTrack的典型用法代码示例。如果您正苦于以下问题:C# AudioTrack类的具体用法?C# AudioTrack怎么用?C# AudioTrack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AudioTrack类属于命名空间,在下文中一共展示了AudioTrack类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Start

	public void Start()
    {
        _currentTrack = AudioTrack.RabbitHole;
        _currentSourceIndex = 0;

        StartCoroutine("PlayPark");
	}
开发者ID:WozStudios,项目名称:AVirtualWonderland,代码行数:7,代码来源:AudioManager.cs


示例2: btnPlay_Click

        private void btnPlay_Click(object sender, RoutedEventArgs e)
        {
            AudioTrack _audioTrack = new AudioTrack(new Uri(fileName, UriKind.Relative),"歌曲名", "艺术家", "专辑", null);
            BackgroundAudioPlayer.Instance.Track = _audioTrack;

            BackgroundAudioPlayer.Instance.Play();
        }
开发者ID:hebecherish,项目名称:WP8AppDemo,代码行数:7,代码来源:MainPage.xaml.cs


示例3: OnUserAction

        protected override void OnUserAction(BackgroundAudioPlayer player, AudioTrack track, UserAction action, object param)
        {
            switch (action)
            {
                case UserAction.Play:
                    if (PlayState.Playing != player.PlayerState)
                    {
                        player.Play();
                    }
                    break;

                case UserAction.Stop:
                    player.Stop();
                    break;

                case UserAction.Pause:
                    if (PlayState.Playing == player.PlayerState)
                    {
                        player.Pause();
                    }
                    break;
                case UserAction.Rewind:
                  player.Position = player.Position.Subtract(new TimeSpan(0,0,10));
                    break;

                case UserAction.FastForward:
                  player.Position = player.Position.Add(new TimeSpan(0,0,10));
                    break;
            }

            NotifyComplete();
        }
开发者ID:juhariis,项目名称:Windows-Phone-Starter-Kit-for-Podcasts,代码行数:32,代码来源:AudioPlayer.cs


示例4: OnBeginStreaming

        /// <summary>
        /// Called when a new track requires audio decoding
        /// (typically because it is about to start playing)
        /// </summary>
        /// <param name="track">
        /// The track that needs audio streaming
        /// </param>
        /// <param name="streamer">
        /// The AudioStreamer object to which a MediaStreamSource should be
        /// attached to commence playback
        /// </param>
        /// <remarks>
        /// To invoke this method for a track set the Source parameter of the AudioTrack to null
        /// before setting  into the Track property of the BackgroundAudioPlayer instance
        /// property set to true;
        /// otherwise it is assumed that the system will perform all streaming
        /// and decoding
        /// </remarks>
        protected override void OnBeginStreaming(AudioTrack track, AudioStreamer streamer)
        {
            //TODO: Set the SetSource property of streamer to a MSS source

            var data = track.Tag.ToString().Split('$');
            var url = data[data.Length - 1];

            var type = data[2];

#if DEBUG
            System.Diagnostics.Debug.WriteLine("AudioStreamer:OnBeginStreaming - Type: " + type);
#endif

            switch (type.ToLower())
            {
                case "shoutcast":
                    {
                        mms = new Silverlight.Media.ShoutcastMediaStreamSource(new Uri(url), true);
                        //track.Title = "Moo";
                        mms.MetadataChanged += mms_MetadataChanged;
                        mms.Connected += mms_Connected;
                        mms.Closed += mms_Closed;
                        streamer.SetSource(mms);
                    }
                    break;
            }
        }
开发者ID:Amrykid,项目名称:Hanasu,代码行数:45,代码来源:AudioStreamer.cs


示例5: OnUserAction

        protected override void OnUserAction(BackgroundAudioPlayer player, AudioTrack track, UserAction action, object param)
        {
            ShellTile mainTile = ShellTile.ActiveTiles.FirstOrDefault();
            switch (action)
            {
                case UserAction.Play:
                    if (PlayState.Paused == player.PlayerState)
                    {
                        player.Play();

                        mainTile.Update(new StandardTileData
                        {
                            BackContent = "Play"
                        });

                    }
                    break;

                case UserAction.Pause:
                    player.Pause();

                    mainTile.Update(new StandardTileData
                    {
                        BackContent = "Pause"
                    });
                    break;
            }
            NotifyComplete();
        }
开发者ID:OlivierRiberi,项目名称:3NET-SimpleRadio,代码行数:29,代码来源:AudioPlayer.cs


示例6: OnPlayStateChanged

        /// <summary>
        /// playstate 更改时调用,但 Error 状态除外(参见 OnError)
        /// </summary>
        /// <param name="player">BackgroundAudioPlayer</param>
        /// <param name="track">在 playstate 更改时播放的曲目</param>
        /// <param name="playState">播放机的新 playstate </param>
        /// <remarks>
        /// 无法取消播放状态更改。即使应用程序
        /// 导致状态自行更改也会提出这些更改,假定应用程序已经选择了回调。
        ///
        /// 值得注意的 playstate 事件:
        /// (a) TrackEnded: 播放器没有当前曲目时激活。代理可设置下一曲目。
        /// (b) TrackReady: 音轨已设置完毕,现在可以播放。
        ///
        /// 只在代理请求完成之后调用一次 NotifyComplete(),包括异步回调。
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            switch (playState)
            {
                case PlayState.TrackEnded:
                    //player.Track = GetPreviousTrack();
                    //player.Track = GetNextTrack();
                    PlayNextTrack(player);
                    break;
                case PlayState.TrackReady:
                    player.Play();
                    break;
                case PlayState.Shutdown:
                    // TODO: 在此处理关机状态(例如保存状态)
                    break;
                case PlayState.Unknown:
                    break;
                case PlayState.Stopped:
                    break;
                case PlayState.Paused:
                    break;
                case PlayState.Playing:
                    break;
                case PlayState.BufferingStarted:
                    break;
                case PlayState.BufferingStopped:
                    break;
                case PlayState.Rewinding:
                    break;
                case PlayState.FastForwarding:
                    break;
            }

            NotifyComplete();
        }
开发者ID:vicalloy,项目名称:lb.ting,代码行数:51,代码来源:AudioPlayer.cs


示例7: OnPlayStateChanged

        /// <summary>
        /// Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        /// Play State changes cannot be cancelled. They are raised even if the application
        /// caused the state change itself, assuming the application has opted-in to the callback.
        /// 
        /// Notable playstate events: 
        /// (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        /// (b) TrackReady: an audio track has been set and it is now ready for playack.
        /// 
        /// Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            switch (playState)
            {
                case PlayState.TrackEnded:
                    player.Track = GetNextTrack();
                    break;
                case PlayState.TrackReady:
                    player.Play();
                    break;
                case PlayState.Shutdown:
                    // TODO: Handle the shutdown state here (e.g. save state)
                    break;
                case PlayState.Unknown:
                    break;
                case PlayState.Stopped:
                    _playlistHelper.SetAllTracksToNotPlayingAndSave();
                    break;
                case PlayState.Paused:
                    break;
                case PlayState.Playing:
                    break;
                case PlayState.BufferingStarted:
                    break;
                case PlayState.BufferingStopped:
                    break;
                case PlayState.Rewinding:
                    break;
                case PlayState.FastForwarding:
                    break;
            }

            NotifyComplete();
        }
开发者ID:EchoDemon,项目名称:MediaBrowser.WindowsPhone,代码行数:50,代码来源:AudioPlayer.cs


示例8: OnPlayStateChanged

        /// <summary>
        ///     Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        ///     Play State changes cannot be cancelled. They are raised even if the application
        ///     caused the state change itself, assuming the application has opted-in to the callback.
        ///     Notable playstate events:
        ///     (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        ///     (b) TrackReady: an audio track has been set and it is now ready for playack.
        ///     Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            Debug.WriteLine("OnPlayStateChanged() playState " + playState);

            switch (playState)
            {
                case PlayState.TrackEnded:
                    player.Track = GetPreviousTrack();
                    break;
                case PlayState.TrackReady:
                    player.Play();
                    break;
                case PlayState.Shutdown:
                    // TODO: Handle the shutdown state here (e.g. save state)
                    break;
                case PlayState.Unknown:
                    break;
                case PlayState.Stopped:
                    break;
                case PlayState.Paused:
                    break;
                case PlayState.Playing:
                    break;
                case PlayState.BufferingStarted:
                    break;
                case PlayState.BufferingStopped:
                    break;
                case PlayState.Rewinding:
                    break;
                case PlayState.FastForwarding:
                    break;
            }

            NotifyComplete();
        }
开发者ID:henricj,项目名称:HttpClientBackgroundAudio,代码行数:49,代码来源:AudioPlayer.cs


示例9: OnUserAction

 /// <summary>
 /// Called when the user requests an action using system-provided UI and the application has requesed
 /// notifications of the action
 /// </summary>
 /// <param name="player">The BackgroundAudioPlayer</param>
 /// <param name="track">The track playing at the time of the user action</param>
 /// <param name="action">The action the user has requested</param>
 /// <param name="param">The data associated with the requested action.
 /// In the current version this parameter is only for use with the Seek action,
 /// to indicate the requested position of an audio track</param>
 /// <remarks>
 /// User actions do not automatically make any changes in system state; the agent is responsible
 /// for carrying out the user actions if they are supported
 /// </remarks>
 protected override void OnUserAction(BackgroundAudioPlayer player, AudioTrack track, UserAction action, object param)
 {
     if (action == UserAction.Play)
         player.Play();
     else if (action == UserAction.Pause)
         player.Pause();
     NotifyComplete();
 }
开发者ID:whrxiao,项目名称:Windows-Phone-7-In-Action,代码行数:22,代码来源:AudioPlayer.cs


示例10: GetTrackOption

        public bool GetTrackOption(AudioTrack option)
        {
            int index = (int)option;
            Debug.Assert((index >= 0) && (index < AudioPlugin2DViewSettings.cAudioTrackCount));

            lock (AudioPlugin2DViewSettings.lockObj)
            {
                return this.options[index];
            }
        }
开发者ID:UnaNancyOwen,项目名称:Kinect-Studio-Sample,代码行数:10,代码来源:AudioPlugin2DViewSettings.cs


示例11: OnPlayStateChanged

 protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
 {
     switch (playState)
     {
         case PlayState.TrackReady:
             player.Play();
             break;
     }
     NotifyComplete();
 }
开发者ID:OlivierRiberi,项目名称:3NET-SimpleRadio,代码行数:10,代码来源:AudioPlayer.cs


示例12: OnError

 /// <summary>
 /// Called whenever there is an error with playback, such as an AudioTrack not downloading correctly
 /// </summary>
 /// <param name="player">The BackgroundAudioPlayer</param>
 /// <param name="track">The track that had the error</param>
 /// <param name="error">The error that occured</param>
 /// <param name="isFatal">If true, playback cannot continue and playback of the track will stop</param>
 /// <remarks>
 /// This method is not guaranteed to be called in all cases. For example, if the background agent
 /// itself has an unhandled exception, it won't get called back to handle its own errors.
 /// </remarks>
 protected override void OnError(BackgroundAudioPlayer player, AudioTrack track, Exception error, bool isFatal)
 {
     if (isFatal)
     {
         Abort();
     }
     else
     {
         NotifyComplete();
     }
 }
开发者ID:vladk1,项目名称:Kaizen,代码行数:22,代码来源:AudioPlayer.cs


示例13: OnBeginStreaming

        protected override void OnBeginStreaming(AudioTrack track, AudioStreamer streamer)
        {
            System.Diagnostics.Debug.WriteLine("OnBeginStreaming");
            MidiStreamSource mss = new MidiStreamSource();

            // Event handler for when a track is complete or the user switches tracks
            mss.StreamComplete += new EventHandler(mss_StreamComplete);

            // Set the source
            streamer.SetSource(mss);
        }
开发者ID:rick-li,项目名称:midi-browser,代码行数:11,代码来源:AudioStreamer.cs


示例14: OnBeginStreaming

        /// <summary>
        /// Called when a new track requires audio decoding
        /// (typically because it is about to start playing)
        /// </summary>
        /// <param name="track">
        /// The track that needs audio streaming
        /// </param>
        /// <param name="streamer">
        /// The AudioStreamer object to which a MediaStreamSource should be
        /// attached to commence playback
        /// </param>
        /// <remarks>
        /// To invoke this method for a track set the Source parameter of the AudioTrack to null
        /// before setting  into the Track property of the BackgroundAudioPlayer instance
        /// property set to true;
        /// otherwise it is assumed that the system will perform all streaming
        /// and decoding
        /// </remarks>
        protected override void OnBeginStreaming(AudioTrack track, Microsoft.Phone.BackgroundAudio.AudioStreamer streamer)
        {
            //using (var iso = IsolatedStorageFile.GetUserStoreForApplication())
            //{
            var iso = IsolatedStorageFile.GetUserStoreForApplication();
                string filePath = track.Tag;
                var exist = iso.FileExists(filePath);
                streamer.SetSource(new Mp3MediaStreamSource(iso.OpenFile(filePath, FileMode.Open, FileAccess.Read)));
            //}

            NotifyComplete();
        }
开发者ID:journeyman,项目名称:PodcastReader,代码行数:30,代码来源:AudioStreamer.cs


示例15: AudioPlayer

 /// <remarks>
 /// AudioPlayer instances can share the same process. 
 /// Static fields can be used to share state between AudioPlayer instances
 /// or to communicate with the Audio Streaming agent.
 /// </remarks>
 public AudioPlayer()
 {
     audio = new AudioTrack();
     if (!_classInitialized)
     {
         _classInitialized = true;
         // Subscribe to the managed exception handler
         Deployment.Current.Dispatcher.BeginInvoke(delegate
         {
             Application.Current.UnhandledException += AudioPlayer_UnhandledException;
         });
     }
 }
开发者ID:mikejan,项目名称:EntacikGorc,代码行数:18,代码来源:AudioPlayer.cs


示例16: OnPlayStateChanged

        /// <summary>
        /// Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        /// Play State changes cannot be cancelled. They are raised even if the application
        /// caused the state change itself, assuming the application has opted-in to the callback.
        ///
        /// Notable playstate events:
        /// (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        /// (b) TrackReady: an audio track has been set and it is now ready for playack.
        ///
        /// Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            switch (playState)
            {
                case PlayState.TrackEnded:
                    //player.Track = GetPreviousTrack();
                    player.Track = null;
                    break;
                case PlayState.TrackReady:
                    player.Play();
                    connectedEvent.Set();

                    if (track != null && track.Tag != null)
                    {
                        var data = track.Tag.ToString().Split('$');
                        var url = data[data.Length - 1];
                        var title = data[1];
                        var type = data[2];

                        //#region from http://stackoverflow.com/questions/7159900/detect-application-launch-from-universal-volume-control
                        //MediaHistoryItem nowPlaying = new MediaHistoryItem();
                        //nowPlaying.Title = title;
                        //nowPlaying.PlayerContext.Add("station", title);
                        //MediaHistory.Instance.NowPlaying = nowPlaying;
                        //#endregion
                    }
                    break;
                case PlayState.Shutdown:
                    // TODO: Handle the shutdown state here (e.g. save state)
                    break;
                case PlayState.Unknown:
                    break;
                case PlayState.Stopped:
                    break;
                case PlayState.Paused:
                    break;
                case PlayState.Playing:
                    break;
                case PlayState.BufferingStarted:
                    break;
                case PlayState.BufferingStopped:
                    break;
                case PlayState.Rewinding:
                    break;
                case PlayState.FastForwarding:
                    break;
            }

            NotifyComplete();
        }
开发者ID:Amrykid,项目名称:Hanasu,代码行数:66,代码来源:AudioPlayer.cs


示例17: handleDragInteraction

 private void handleDragInteraction(Rect position, AudioTrack track, Vector2 translation, Vector2 scale)
 {
     Rect controlBackground = new Rect(0, 0, position.width, position.height);
     switch (Event.current.type)
     {
         case EventType.DragUpdated:
             if (controlBackground.Contains(Event.current.mousePosition))
             {
                 bool audioFound = false;
                 foreach (Object objectReference in DragAndDrop.objectReferences)
                 {
                     AudioClip clip = objectReference as AudioClip;
                     if (clip != null)
                     {
                         audioFound = true;
                         break;
                     }
                 }
                 if (audioFound)
                 {
                     DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                     Event.current.Use();
                 }
             }
             break;
         case EventType.DragPerform:
             if (controlBackground.Contains(Event.current.mousePosition))
             {
                 AudioClip clip = null;
                 foreach (Object objectReference in DragAndDrop.objectReferences)
                 {
                     AudioClip audioClip = objectReference as AudioClip;
                     if (audioClip != null)
                     {
                         clip = audioClip;
                         break;
                     }
                 }
                 if (clip != null)
                 {
                     float fireTime = (Event.current.mousePosition.x - translation.x) / scale.x;
                     CinemaAudio ca = CutsceneItemFactory.CreateCinemaAudio(track, clip, fireTime);
                     Undo.RegisterCreatedObjectUndo(ca, string.Format("Created {0}", ca.name));
                     Event.current.Use();
                 }
             }
             break;
     }
 }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:49,代码来源:AudioTrackControl.cs


示例18: createProgressTone

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static android.media.AudioTrack createProgressTone(android.content.Context context) throws java.io.IOException
		private static AudioTrack createProgressTone(Context context)
		{
			AssetFileDescriptor fd = context.Resources.openRawResourceFd(R.raw.progress_tone);
			int length = (int) fd.Length;

			AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL, SAMPLE_RATE, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, length, AudioTrack.MODE_STATIC);

			sbyte[] data = new sbyte[length];
			readFileToBytes(fd, data);

			audioTrack.write(data, 0, data.Length);
			audioTrack.setLoopPoints(0, data.Length / 2, 30);

			return audioTrack;
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:17,代码来源:AudioPlayer.cs


示例19: OnPlayStateChanged

        /// <summary>
        /// Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        /// Play State changes cannot be cancelled. They are raised even if the application
        /// caused the state change itself, assuming the application has opted-in to the callback.
        /// 
        /// Notable playstate events: 
        /// (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        /// (b) TrackReady: an audio track has been set and it is now ready for playack.
        /// 
        /// Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            switch (playState)
            {
                case PlayState.TrackReady:
                    // Wiedergabe wurde in PlayTrack() bereits festgelegt
                    player.Play();
                    break;
                case PlayState.TrackEnded:
                    PlayNextTrack(player);
                    break;
            }

            NotifyComplete();
        }
开发者ID:GregOnNet,项目名称:WP8BookSamples,代码行数:31,代码来源:AudioPlayer.cs


示例20: OnUserAction

        /// <summary>
        /// Called when the user requests an action using system-provided UI and the application has requesed
        /// notifications of the action
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time of the user action</param>
        /// <param name="action">The action the user has requested</param>
        /// <param name="param">The data associated with the requested action.
        /// In the current version this parameter is only for use with the Seek action,
        /// to indicate the requested position of an audio track</param>
        /// <remarks>
        /// User actions do not automatically make any changes in system state; the agent is responsible
        /// for carrying out the user actions if they are supported
        /// </remarks>
        protected override void OnUserAction(BackgroundAudioPlayer player, AudioTrack track, UserAction action,
                                             object param)
        {
            switch (action)
            {
                case UserAction.Play:
                    playTrack(player);
                    break;

                case UserAction.Stop:
                    player.Stop();
                    break;
            }

            NotifyComplete();
        }
开发者ID:woodgate,项目名称:MegastrazWP7,代码行数:30,代码来源:AudioPlayer.cs



注:本文中的AudioTrack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AudioType类代码示例发布时间:2022-05-24
下一篇:
C# AudioManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap