Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
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
videolan
vlc
Commits
45dbbcc4
Commit
45dbbcc4
authored
Feb 23, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Media event handling
parent
c05739b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
14 deletions
+127
-14
bindings/cil/src/media.cs
bindings/cil/src/media.cs
+118
-10
bindings/cil/tests/testvlc.cs
bindings/cil/tests/testvlc.cs
+9
-4
No files found.
bindings/cil/src/media.cs
View file @
45dbbcc4
...
...
@@ -42,6 +42,30 @@ namespace VideoLAN.LibVLC
}
};
/**
* @brief MetaType: type of a media meta-information entry
*/
public
enum
MetaType
{
Title
,
Artist
,
Genre
,
Copyright
,
Album
,
TrackNumber
,
Description
,
Rating
,
Date
,
Setting
,
URL
,
Language
,
NowPlaying
,
Publisher
,
EncodedBy
,
ArtworkURL
,
TrackID
,
};
/**
* @brief State: media/player state
*
...
...
@@ -60,6 +84,45 @@ namespace VideoLAN.LibVLC
Error
,
/**< Failed */
};
/* Media events */
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
sealed
class
MediaMetaEvent
:
GenericEvent
{
public
MetaType
metaType
;
};
internal
delegate
void
MediaMetaCallback
(
MediaMetaEvent
e
,
IntPtr
d
);
/*[StructLayout (LayoutKind.Sequential)]
internal sealed class MediaSubitemEvent : GenericEvent
{
public IntPtr child; -- MediaHandle
};*/
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
sealed
class
MediaDurationEvent
:
GenericEvent
{
public
long
duration
;
};
internal
delegate
void
MediaDurationCallback
(
MediaDurationEvent
e
,
IntPtr
d
);
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
sealed
class
MediaPreparseEvent
:
GenericEvent
{
public
int
status
;
};
internal
delegate
void
MediaPreparseCallback
(
MediaPreparseEvent
e
,
IntPtr
d
);
/* media_freed -> bad idea w.r.t. the GC */
[
StructLayout
(
LayoutKind
.
Sequential
)]
internal
sealed
class
MediaStateEvent
:
GenericEvent
{
public
State
state
;
};
internal
delegate
void
MediaStateCallback
(
MediaStateEvent
e
,
IntPtr
d
);
/**
* @brief Media: a source media
* @ingroup API
...
...
@@ -87,6 +150,35 @@ namespace VideoLAN.LibVLC
handle
=
LibVLC
.
MediaCreate
(
instance
.
Handle
,
umrl
,
ex
);
Raise
();
Attach
();
}
private
Media
(
MediaHandle
handle
)
{
this
.
handle
=
handle
;
Attach
();
}
/**
* Duplicates a media object.
*/
public
object
Clone
()
{
return
new
Media
(
LibVLC
.
MediaDuplicate
(
Handle
));
}
private
void
Attach
()
{
Attach
(
EventType
.
MediaMetaChanged
,
new
MediaMetaCallback
(
MetaCallback
));
//Attach (EventType.MediaSubItemAdded, SubItemAdded);
Attach
(
EventType
.
MediaDurationChanged
,
new
MediaDurationCallback
(
DurationCallback
));
/*Attach (EventType.MediaPreparsedChanged,
new MediaPreparseCallback (PreparseCallback));*/
/* MediaFreed: better not... */
Attach
(
EventType
.
MediaStateChanged
,
new
MediaStateCallback
(
StateCallback
));
}
/**
...
...
@@ -128,17 +220,9 @@ namespace VideoLAN.LibVLC
}
}
p
rivate
Media
(
MediaHandle
handle
)
p
ublic
override
string
ToString
(
)
{
this
.
handle
=
handle
;
}
/**
* Duplicates a media object.
*/
public
object
Clone
()
{
return
new
Media
(
LibVLC
.
MediaDuplicate
(
Handle
));
return
Location
;
}
/**
...
...
@@ -154,6 +238,14 @@ namespace VideoLAN.LibVLC
}
}
public
delegate
void
StateChange
(
Media
media
,
State
state
);
public
event
StateChange
StateChanged
;
private
void
StateCallback
(
MediaStateEvent
ev
,
IntPtr
data
)
{
if
(
StateChanged
!=
null
)
StateChanged
(
this
,
ev
.
state
);
}
internal
override
EventManagerHandle
GetManager
()
{
return
LibVLC
.
MediaEventManager
(
Handle
,
null
);
...
...
@@ -174,6 +266,14 @@ namespace VideoLAN.LibVLC
}
}
public
delegate
void
DurationChange
(
Media
media
,
long
duration
);
public
event
DurationChange
DurationChanged
;
private
void
DurationCallback
(
MediaDurationEvent
ev
,
IntPtr
data
)
{
if
(
DurationChanged
!=
null
)
DurationChanged
(
this
,
ev
.
duration
);
}
/**
* Whether the media was "preparsed". If true, the meta-infos were
* extracted, even before the media was played. This is normally only
...
...
@@ -188,5 +288,13 @@ namespace VideoLAN.LibVLC
return
preparsed
!=
0
;
}
}
public
delegate
void
PreparseChange
(
Media
media
,
bool
preparsed
);
public
event
PreparseChange
PreparseChanged
;
private
void
PreparseCallback
(
MediaPreparseEvent
ev
,
IntPtr
data
)
{
if
(
PreparseChanged
!=
null
)
PreparseChanged
(
this
,
ev
.
status
!=
0
);
}
};
};
bindings/cil/tests/testvlc.cs
View file @
45dbbcc4
...
...
@@ -30,10 +30,14 @@ namespace VideoLAN.LibVLC.Test
{
private
static
void
DumpMedia
(
Media
m
)
{
Console
.
WriteLine
(
"Media at {0}"
,
m
.
Location
);
Console
.
WriteLine
(
" duration: {0}µs"
,
m
.
Duration
);
Console
.
WriteLine
(
" preparsed: {0}"
,
m
.
IsPreparsed
);
Console
.
WriteLine
(
" state: {0}"
,
m
.
State
);
Console
.
WriteLine
(
"Media: {0} {1} (duration: {2}, {3}preparsed)"
,
m
.
State
,
m
.
Location
,
m
.
Duration
,
m
.
IsPreparsed
?
""
:
"not "
);
}
private
static
void
WriteMediaState
(
Media
m
,
State
s
)
{
Console
.
WriteLine
(
" -> {0}"
,
s
);
}
private
static
void
DumpPlayer
(
Player
p
)
...
...
@@ -69,6 +73,7 @@ namespace VideoLAN.LibVLC.Test
DumpMedia
(
media
);
DumpMedia
((
Media
)
media
.
Clone
());
media
.
StateChanged
+=
WriteMediaState
;
player
.
Play
();
do
...
...
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