コード例 #1
0
        private SoundChannel internalPlay(double startTime = 0, int loops = 0, SoundTransform sndTransform = null)
        {
            if (player == null)
            {
                Console.WriteLine("MediaPlayer is null");
                return(null);
            }

            loops = Math.Max(0, loops);

            player.SetLoopsCount(loops);

            if (startTime > 0)
            {
                Console.WriteLine("Warning: Sounds StartTime is not supported");
            }

            try {
                // if the player is stopped, we need to initialize it again
                if (!player.isInitialize())
                {
                    player.Initialize();
                }
            } catch (Exception e) {
                Console.WriteLine("Exception occur initializing sounds. " + e.Message);
                this.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR));
                player.Release();
                player = null;
                return(null);
            }

            player.Start();

            return(channel);
        }
コード例 #2
0
        private void internalLoad(String url)
        {
            player = new ZMediaPlayer(url, channel);


            try {
                if (playerQueue.Count == SIZE)
                {
                    ZMediaPlayer oldPlayer = playerQueue.Dequeue();
                    oldPlayer.Release();
                }

                player.Initialize();
                playerQueue.Enqueue(player);
            } catch (Exception e) {
                Console.WriteLine("Exception occur loading sounds. " + e.Message);
                this.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR));
                player.Release();
                player = null;
                return;
            }

            this.dispatchEvent(new Event(Event.COMPLETE));
        }