Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LibVLCSharp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Finkel
LibVLCSharp
Commits
52abb3c9
Commit
52abb3c9
authored
May 07, 2018
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VideoView is a View, not an activity
parent
0dac1158
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
53 deletions
+74
-53
LibVLCSharp.Android.Sample/MainActivity.cs
LibVLCSharp.Android.Sample/MainActivity.cs
+18
-8
LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs
LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs
+0
-16
LibVLCSharp.Android.Sample/Resources/layout/Main.axml
LibVLCSharp.Android.Sample/Resources/layout/Main.axml
+0
-7
LibVLCSharp/Platforms/Android/VideoView.cs
LibVLCSharp/Platforms/Android/VideoView.cs
+53
-18
LibVLCSharp/Shared/IVideoView.cs
LibVLCSharp/Shared/IVideoView.cs
+3
-4
No files found.
LibVLCSharp.Android.Sample/MainActivity.cs
View file @
52abb3c9
using
Android.App
;
using
Android.OS
;
using
Android.Views
;
using
LibVLCSharp.Platforms.Android
;
using
Android.Widget
;
using
LibVLCSharp.Shared
;
using
VideoView
=
LibVLCSharp
.
Platforms
.
Android
.
VideoView
;
namespace
LibVLCSharp.Android.Sample
{
[
Activity
(
Label
=
"LibVLCSharp.Android.Sample"
,
MainLauncher
=
true
)]
public
class
MainActivity
:
VideoView
public
class
MainActivity
:
Activity
{
SurfaceView
_surface
View
;
VideoView
_video
View
;
protected
override
void
OnCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -17,16 +18,25 @@ namespace LibVLCSharp.Android.Sample
// Set our view from the "main" layout resource
SetContentView
(
Resource
.
Layout
.
Main
);
_surfaceView
=
FindViewById
<
SurfaceView
>(
Resource
.
Id
.
surfaceView
);
AttachSurfaceView
(
_surfaceView
);
}
protected
override
void
OnResume
()
{
base
.
OnResume
();
MediaPlayer
.
Play
(
new
Media
(
Instance
,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"
,
Media
.
FromType
.
FromLocation
));
_videoView
=
new
VideoView
(
this
);
AddContentView
(
_videoView
,
new
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WrapContent
,
ViewGroup
.
LayoutParams
.
WrapContent
));
_videoView
.
Attach
();
_videoView
.
MediaPlayer
.
Play
(
new
Media
(
_videoView
.
Instance
,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"
,
Media
.
FromType
.
FromLocation
));
}
protected
override
void
OnPause
()
{
base
.
OnPause
();
_videoView
.
MediaPlayer
.
Stop
();
_videoView
.
Detach
();
_videoView
.
Dispose
();
}
}
}
\ No newline at end of file
LibVLCSharp.Android.Sample/Resources/Resource.Designer.cs
View file @
52abb3c9
...
...
@@ -41,22 +41,6 @@ namespace LibVLCSharp.Android.Sample
}
}
public
partial
class
Id
{
// aapt resource value: 0x7f040000
public
const
int
surfaceView
=
2130968576
;
static
Id
()
{
global
::
Android
.
Runtime
.
ResourceIdManager
.
UpdateIdValues
();
}
private
Id
()
{
}
}
public
partial
class
Layout
{
...
...
LibVLCSharp.Android.Sample/Resources/layout/Main.axml
View file @
52abb3c9
...
...
@@ -3,11 +3,4 @@
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<SurfaceView
android:id=
"@+id/surfaceView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
>
</SurfaceView>
</LinearLayout>
\ No newline at end of file
LibVLCSharp/Platforms/Android/VideoView.cs
View file @
52abb3c9
using
Android.App
;
using
Android.OS
;
using
System
;
using
Android.Content
;
using
Android.Runtime
;
using
Android.Util
;
using
Android.Views
;
using
LibVLCSharp.Shared
;
using
Org.Videolan.Libvlc
;
namespace
LibVLCSharp.Platforms.Android
{
[
Activity
(
Label
=
"VideoView"
)]
public
abstract
class
VideoView
:
Activity
,
IVLCVoutCallback
public
class
VideoView
:
SurfaceView
,
IVLCVoutCallback
,
IVideoView
{
MediaPlayer
_mediaPlayer
;
Instance
_instance
;
AWindow
_awindow
;
LayoutChangeListener
_layoutListener
;
protected
override
void
OnCreate
(
Bundle
savedInstanceState
)
{
base
.
OnCreate
(
savedInstanceState
);
#
region
ctors
Core
.
Initialize
();
public
VideoView
(
IntPtr
javaReference
,
JniHandleOwnership
transfer
)
:
base
(
javaReference
,
transfer
)
=>
Init
();
_instance
=
new
Instance
();
_mediaPlayer
=
new
MediaPlayer
(
_instance
);
public
VideoView
(
Context
context
)
:
base
(
context
)
=>
Init
();
public
VideoView
(
Context
context
,
IAttributeSet
attrs
)
:
base
(
context
,
attrs
)
=>
Init
();
public
VideoView
(
Context
context
,
IAttributeSet
attrs
,
int
defStyleAttr
)
:
base
(
context
,
attrs
,
defStyleAttr
)
=>
Init
();
public
VideoView
(
Context
context
,
IAttributeSet
attrs
,
int
defStyleAttr
,
int
defStyleRes
)
:
base
(
context
,
attrs
,
defStyleAttr
,
defStyleRes
)
=>
Init
();
#
endregion
public
MediaPlayer
MediaPlayer
=>
_mediaPlayer
;
public
Instance
Instance
=>
_instance
;
public
void
Attach
()
{
_awindow
=
new
AWindow
(
new
SurfaceCallback
(
_mediaPlayer
));
_awindow
.
AddCallback
(
this
);
_awindow
.
SetVideoView
(
this
);
_awindow
.
AttachViews
();
_mediaPlayer
.
SetAndroidContext
(
_awindow
.
Handle
);
_layoutListener
=
new
LayoutChangeListener
(
_awindow
);
AddOnLayoutChangeListener
(
_layoutListener
);
}
public
void
AttachSurfaceView
(
SurfaceView
surfaceView
)
public
void
Detach
(
)
{
_awindow
.
SetVideoView
(
surfaceView
);
_awindow
.
AttachViews
();
surfaceView
.
AddOnLayoutChangeListener
(
new
LayoutChangeListener
(
_awindow
));
_awindow
.
RemoveCallback
(
this
);
_awindow
.
DetachViews
();
_mediaPlayer
.
SetAndroidContext
(
IntPtr
.
Zero
);
RemoveOnLayoutChangeListener
(
_layoutListener
);
_layoutListener
.
Dispose
();
_layoutListener
=
null
;
_awindow
.
Dispose
();
_awindow
=
null
;
}
public
virtual
void
OnSurfacesCreated
(
IVLCVout
p0
)
public
virtual
void
OnSurfacesCreated
(
IVLCVout
vout
)
{
}
public
virtual
void
OnSurfacesDestroyed
(
IVLCVout
p0
)
public
virtual
void
OnSurfacesDestroyed
(
IVLCVout
vout
)
{
}
public
MediaPlayer
MediaPlayer
=>
_mediaPlayer
;
public
Instance
Instance
=>
_instance
;
void
Init
()
{
Core
.
Initialize
();
_instance
=
new
Instance
();
_mediaPlayer
=
new
MediaPlayer
(
_instance
);
}
}
}
\ No newline at end of file
LibVLCSharp/Shared/IVideoView.cs
View file @
52abb3c9
...
...
@@ -3,10 +3,9 @@
public
interface
IVideoView
{
MediaPlayer
MediaPlayer
{
get
;
}
Instance
Instance
{
get
;
}
void
Attach
View
(
object
surface
);
void
Detach
View
();
void
Attach
(
);
void
Detach
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment