Advertisement
WindowsTV

Homeroom Broadcast

Sep 18th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.89 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.ComponentModel;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace Homeroom_Brodcast_Custom_Player
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.  
  17.         string file = Path.Combine(AppDomain.CurrentDomain
  18.             .BaseDirectory, "Data\\Brodcast.avi");
  19.  
  20.         string dataPath = Path.Combine(AppDomain.CurrentDomain
  21.             .BaseDirectory, "Data\\");
  22.  
  23.         public Form1()
  24.         {
  25.             InitializeComponent();
  26.             openFileDialog1.InitialDirectory = dataPath;
  27.             axWindowsMediaPlayer1.BringToFront();
  28.             //AppDomain.CurrentDomain.BaseDirectory;
  29.         }
  30.  
  31.         private void Form1_Load(object sender, EventArgs e)
  32.         {
  33.             //(Full Name) Jolt Imagination Live Loader
  34.             if (!File.Exists(file) && !BrowseFile())
  35.             {
  36.                 Application.Exit();
  37.                 return;
  38.             }
  39.  
  40.             axWindowsMediaPlayer1.URL = file;
  41.             Cursor.Hide();
  42.             FormBorderStyle = FormBorderStyle.None;
  43.             WindowState = FormWindowState.Maximized;
  44.         }
  45.  
  46.         private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
  47.         {
  48.             if (e.newState == 8)
  49.             {
  50.                 pictureBox1.Image = Homeroom_Brodcast_Custom_Player.Properties.Resources.main_jpeg;
  51.                 pictureBox1.BringToFront();
  52.                 pictureBox1.Width = Screen.PrimaryScreen.Bounds.Width;
  53.                 pictureBox1.Height = Screen.PrimaryScreen.Bounds.Height;
  54.             }
  55.         }
  56.  
  57.         public bool BrowseFile()
  58.         {
  59.             DialogResult dialogResult = openFileDialog1.ShowDialog();
  60.             if (dialogResult == DialogResult.OK)
  61.             {
  62.                 file = openFileDialog1.FileName;
  63.                 return true;
  64.             }
  65.             else return false;
  66.         }
  67.  
  68.         private void axWindowsMediaPlayer1_KeyPressEvent(object sender, AxWMPLib._WMPOCXEvents_KeyPressEvent e)
  69.         {
  70.             if (e.nKeyAscii == 27) this.Close();
  71.         }
  72.  
  73.         private void timer1_Tick(object sender, EventArgs e)
  74.         {
  75.             Console.WriteLine(DateTime.Now.ToLongTimeString());
  76.             if (DateTime.Now.ToLongTimeString() == "10:20:00 AM")
  77.             {
  78.                 doRepeat();
  79.             }
  80.             else if (DateTime.Now.ToLongTimeString() == "10:55:00 AM")
  81.             {
  82.                 doRepeat();
  83.             }
  84.             else if (DateTime.Now.ToLongTimeString() == "11:10:00 AM")
  85.             {
  86.                 doRepeat();
  87.             }
  88.             else if (DateTime.Now.ToLongTimeString() == "11:45:00 AM")
  89.             {
  90.                 doRepeat();
  91.             }
  92.             else if (DateTime.Now.ToLongTimeString() == "12:00:00 PM")
  93.             {
  94.                 doRepeat();
  95.             }
  96.             else if (DateTime.Now.ToLongTimeString() == "12:35:00 PM")
  97.             {
  98.                 doRepeat();
  99.             }
  100.             else if (DateTime.Now.ToLongTimeString() == "12:45:00 PM")
  101.             {
  102.                 Cursor.Show();
  103.                 timer1.Enabled = false;
  104.                 DialogResult dialogResult = MessageBox.Show("All homerooms are over. Would you like to exit the program?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  105.                 if (dialogResult == DialogResult.Yes)
  106.                 {
  107.                     this.Close();
  108.                 }
  109.             }
  110.         }
  111.         private void doRepeat()
  112.         {
  113.             Console.WriteLine("Play");
  114.             axWindowsMediaPlayer1.BringToFront();
  115.             axWindowsMediaPlayer1.Ctlcontrols.currentPosition = 0;
  116.             axWindowsMediaPlayer1.Ctlcontrols.play();
  117.         }
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement