⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axmediaplayer_creator.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc.BizControls
{
    using AxWMPLib;
    using Imps.Client.Utils;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    public class axmediaplayer_creator
    {
        private bool m_ax_startuped;
        private object m_ax_startuped_lock = new object();
        private Queue<create_job> m_job_queue = new Queue<create_job>();
        private Timer m_timer = new Timer();
        private static axmediaplayer_creator ms_inst = new axmediaplayer_creator();

        private axmediaplayer_creator()
        {
            this.m_timer.Interval = 500;
            this.m_timer.Tick += new EventHandler(this.on_timer_tick);
        }

        private void add_job(create_job job)
        {
            lock (this.m_job_queue)
            {
                this.m_job_queue.Enqueue(job);
                if (1 == this.m_job_queue.get_Count())
                {
                    this.m_timer.Start();
                }
            }
        }

        public void create_player(Control owner, create_player_callback_proc proc, object context)
        {
            if ((owner == null) || (proc == null))
            {
                throw new ArgumentNullException("owner or proc");
            }
            if (!this.m_ax_startuped)
            {
                lock (this.m_ax_startuped_lock)
                {
                    if (!this.m_ax_startuped)
                    {
                        create_job job = new create_job(owner, proc, context);
                        this.add_job(job);
                    }
                    else
                    {
                        this.sync_create_player(owner, proc, context);
                    }
                    return;
                }
            }
            this.sync_create_player(owner, proc, context);
        }

        private void on_timer_tick(object sender, EventArgs e)
        {
            bool flag = false;
            lock (this.m_job_queue)
            {
                while (0 < this.m_job_queue.get_Count())
                {
                    create_job _job = this.m_job_queue.Dequeue();
                    if (this.sync_create_player(_job.owner, _job.proc, _job.context))
                    {
                        flag = true;
                    }
                }
            }
            if (flag)
            {
                lock (this.m_ax_startuped_lock)
                {
                    this.m_ax_startuped = true;
                }
                this.m_timer.Stop();
                this.m_timer.Dispose();
            }
        }

        private bool sync_create_player(Control owner, create_player_callback_proc proc, object context)
        {
            AxWindowsMediaPlayer player = null;
            bool flag = false;
            try
            {
                if (owner.IsHandleCreated && !owner.IsDisposed)
                {
                    player = new AxWindowsMediaPlayer();
                    ComponentResourceManager manager = new ComponentResourceManager(owner.GetType());
                    player.BeginInit();
                    player.Enabled = true;
                    player.Visible = false;
                    player.Name = "axWindowsMediaPlayer";
                    player.OcxState = (AxHost.State) manager.GetObject("axWindowsMediaPlayer.OcxState");
                    player.TabIndex = owner.Controls.get_Count();
                    owner.Controls.Add(player);
                    player.EndInit();
                    flag = true;
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException("Failed to create Media Player component.", exception);
            }
            proc(owner, flag ? player : null, context);
            return flag;
        }

        public static axmediaplayer_creator instance
        {
            get
            {
                return ms_inst;
            }
        }

        private class create_job
        {
            public object context;
            public Control owner;
            public axmediaplayer_creator.create_player_callback_proc proc;

            public create_job(Control owner, axmediaplayer_creator.create_player_callback_proc proc, object context)
            {
                this.owner = owner;
                this.proc = proc;
                this.context = context;
            }
        }

        public delegate void create_player_callback_proc(Control owner, AxWindowsMediaPlayer axplayer, object context);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -