1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
Imports System.Text
Imports System.ComponentModel
Imports System.Runtime.InteropServices
''' <summary>
''' FlashPlayer UserControl
''' </summary>
''' <remarks>
''' Dieses UserControl hosted über LateBinding einen
''' versionsunabhängigen FlashPlayer.
'''
''' November 2009 - VB-Power.net
''' http://www.vb-power.net
''' </remarks>
Public Class FlashPlayer
Inherits UserControl
Private m_FlashHost As FlashHost
Private m_AutoPlay As Boolean = True
Private m_ColorFrom As Color = Color.Gray
Private m_ColorTo As Color = Color.Gray
Private m_ShowBorder As Boolean = False
Private m_IsPlayerInit As Boolean = False
''' <summary>
''' Controller-Host für den FlashPlayer zur Darstellung
''' in einem UserControl.
''' </summary>
Private Class FlashHost
Inherits AxHost
Public Sub New(ByVal sCLSID As String)
MyBase.New(sCLSID)
End Sub
Public ReadOnly Property Player() As Object
Get
Return Me.GetOcx
End Get
End Property
End Class
''' <summary>
''' Initialisiert das UserControl
''' </summary>
Public Sub New()
Try
' Versionsunabhängiges LateBinding des FlashPlayers
Dim tFlashPlayer As Type = Type.GetTypeFromProgID("ShockwaveFlash.ShockwaveFlash")
If tFlashPlayer IsNot Nothing Then
m_FlashHost = New FlashHost(tFlashPlayer.GUID.ToString)
DirectCast(m_FlashHost, ISupportInitialize).BeginInit()
SuspendLayout()
m_FlashHost.Visible = True
m_FlashHost.Dock = DockStyle.Fill
Controls.Add(m_FlashHost)
DirectCast(m_FlashHost, ISupportInitialize).EndInit()
ResumeLayout(False)
PerformLayout()
m_IsPlayerInit = True
Else
MessageBox.Show("Der FlashPlayer konnte nicht initialisiert werden.", _
"Überprüfung FlashPlayer", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Initialisierung FlashPlayer", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
''' <summary>
''' Legt fest, ob das Video sofort abgespielt werden soll.
''' </summary>
<DefaultValue(GetType(System.Boolean), "True")> _
Public Property AutoPlay() As Boolean
Get
Return m_AutoPlay
End Get
Set(ByVal value As Boolean)
m_AutoPlay = value
End Set
End Property
''' <summary>
''' Legt die erste Verlaufsfarbe für Border und Navigator fest.
''' </summary>
<DefaultValue(GetType(System.Drawing.Color), "Gray")> _
Public Property ColorFrom() As Color
Get
Return m_ColorFrom
End Get
Set(ByVal value As Color)
m_ColorFrom = value
End Set
End Property
''' <summary>
''' Legt die zweite Verlaufsfarbe für Border und Navigator fest.
''' </summary>
<DefaultValue(GetType(System.Drawing.Color), "Gray")> _
Public Property ColorTo() As Color
Get
Return m_ColorTo
End Get
Set(ByVal value As Color)
m_ColorTo = value
End Set
End Property
''' <summary>
''' Zeigt an, ob ein FlashPlayer initialisiert werden konnte.
''' </summary>
<Browsable(False)> _
Public ReadOnly Property IsPlayerInit() As Boolean
Get
Return m_IsPlayerInit
End Get
End Property
''' <summary>
''' Legt fest, ob der Player einen Rahmen angezeigen soll.
''' </summary>
<DefaultValue(GetType(System.Boolean), "False")> _
Public Property ShowBorder() As Boolean
Get
Return m_ShowBorder
End Get
Set(ByVal value As Boolean)
m_ShowBorder = value
End Set
End Property
''' <summary>
''' Spielt das angegebene Video ab.
''' </summary>
''' <param name="URL">Die URL des Videos.</param>
Public Sub PlayMovie(ByVal URL As String)
If Not String.IsNullOrEmpty(URL) Then
Dim sb As New StringBuilder
sb.Append(URL)
sb.AppendFormat("&autoplay={0}", IIf(m_AutoPlay, "1", "0"))
sb.AppendFormat("&color1=0x{0}{1}{2}", String.Format("{0:X2}", m_ColorFrom.R), _
String.Format("{0:X2}", m_ColorFrom.G), String.Format("{0:X2}", m_ColorFrom.B))
sb.AppendFormat("&color2=0x{0}{1}{2}", String.Format("{0:X2}", m_ColorTo.R), _
String.Format("{0:X2}", m_ColorTo.G), String.Format("{0:X2}", m_ColorTo.B))
sb.AppendFormat("&border={0}", IIf(m_ShowBorder, "1", "0"))
m_FlashHost.Player.Movie = sb.ToString
End If
End Sub
End Class
|