Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
VLMC
Commits
0e2a2bad
Commit
0e2a2bad
authored
Apr 02, 2009
by
Hugo Beauzee-Luyssen
Browse files
Snapshot is functionnal, but doesn't seek in media at this time...
parent
b6a13baf
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/LibVLCpp/VLCMediaPlayer.cpp
View file @
0e2a2bad
...
...
@@ -59,7 +59,6 @@ qint64 MediaPlayer::getTime()
void
MediaPlayer
::
setTime
(
qint64
time
)
{
// qDebug() << "Setting media time to " << time;
libvlc_media_player_set_time
(
m_internalPtr
,
time
,
m_ex
);
m_ex
.
checkThrow
();
}
...
...
@@ -68,7 +67,6 @@ qint64 MediaPlayer::getLength()
{
qint64
length
=
libvlc_media_player_get_length
(
m_internalPtr
,
m_ex
);
m_ex
.
checkThrow
();
//qDebug() << "Media length: " << length;
return
length
;
}
...
...
src/Media.cpp
View file @
0e2a2bad
...
...
@@ -21,16 +21,16 @@
*****************************************************************************/
#include
<QtDebug>
#include
<QTemporaryFile>
#include
"Media.h"
Media
::
Media
(
const
QString
&
mrl
)
:
m_mrl
(
mrl
),
m_snapshot
(
NULL
),
m_isThreadLaunched
(
false
),
m_isThreadFinished
(
false
)
Media
::
Media
(
const
QString
&
mrl
)
:
m_mrl
(
mrl
),
m_snapshot
(
NULL
),
m_isThreadLaunched
(
false
),
m_isThreadFinished
(
false
)
{
char
const
*
vlc_argv
[]
=
{
"-verbose"
,
"3"
,
"--no-skip-frames"
,
//"--snapshot-format", "jpg",
//"--plugin-path", VLC_TREE "/modules",
//"--ignore-config", /* Don't use VLC's config files */
};
...
...
@@ -64,6 +64,9 @@ Media::Media( const QString& mrl ) : m_mrl( mrl ), m_snapshot( NULL ), m_isThrea
//And now we play the media
m_vlcMediaPlayer
=
new
LibVLCpp
::
MediaPlayer
(
m_vlcMedia
);
//And launch the checking thread
start
();
}
void
Media
::
run
()
...
...
@@ -74,6 +77,8 @@ void Media::run()
if
(
m_vlcMediaPlayer
->
isSeekable
()
&&
m_vlcMediaPlayer
->
getLength
()
>
0
)
{
m_isMediaInitialized
=
true
;
emit
mediaReady
();
m_isThreadFinished
=
true
;
m_vlcMediaPlayer
->
pause
();
return
;
}
...
...
@@ -104,18 +109,24 @@ void Media::unlock( LibVLCpp::Media::DataCtx* ctx )
QImage
*
Media
::
takeSnapshot
(
unsigned
int
width
,
unsigned
int
height
)
{
//FIXME
//this isn't working, but it seems like a vlc problem, since lastest release of vlc segfault when a screenshot is taken... -_-
return
NULL
;
if
(
m_snapshot
==
NULL
)
{
qDebug
()
<<
"trying to take a snapshot"
;
m_vlcMediaPlayer
->
takeSnapshot
(
"/tmp/vlmcscreenshot.tmp.gif"
,
width
,
height
);
qDebug
()
<<
"done snapshoting"
;
m_snapshot
=
new
QImage
(
"/tmp/vlmcscreenshot.tmp.gif"
);
qDebug
()
<<
"written to a QImage"
;
// qint64 currentTime = m_vlcMediaPlayer->getTime();
// qint64 length = getLength();
// qDebug() << currentTime << length;
// m_vlcMediaPlayer->setTime(length / 2);
// qDebug() << "trying to take a snapshot";
QTemporaryFile
tmp
;
tmp
.
open
();
char
*
tmpStr
=
const_cast
<
char
*>
(
tmp
.
fileName
().
toStdString
().
c_str
());
m_vlcMediaPlayer
->
takeSnapshot
(
tmpStr
,
width
,
height
);
// qDebug() << "done snapshoting";
m_snapshot
=
new
QImage
(
tmp
.
fileName
()
);
// qDebug() << "written to a QImage";
// m_vlcMediaPlayer->setTime(currentTime);
}
return
m_snapshot
;
}
...
...
@@ -130,6 +141,12 @@ bool Media::isSeekable()
return
m_vlcMediaPlayer
->
isSeekable
();
}
bool
Media
::
isReady
()
{
//If the thread has finished without any error, then the media is ready o//
return
m_isMediaInitialized
;
}
qint64
Media
::
getLength
()
{
return
m_vlcMediaPlayer
->
getLength
();
...
...
src/Media.h
View file @
0e2a2bad
...
...
@@ -45,10 +45,31 @@ public:
QImage
*
takeSnapshot
(
unsigned
int
width
,
unsigned
int
heigth
);
/**
* Ask libvlc if the media is currently playing
*/
bool
isPlaying
();
/**
* Ask libvlc if the media can be seeked
*/
bool
isSeekable
();
/**
* Can be used to know if the Media is fully usable (IE. can be seeked, vmem can be used, etc...)
*/
bool
isReady
();
/**
* Return the length (duration) of a Media
*/
qint64
getLength
();
/**
* Returns the last rendered frame
*/
QImage
&
getImage
();
/**
* Start the playback.
* This need to be called at least once in order to prepare the media. if not, the media can't be seeked or anything else.
* When pre-launching is completed, a "mediaReady" signal will be fired.
*/
void
play
();
void
setDrawable
(
int
handle
);
...
...
@@ -69,7 +90,7 @@ private slots:
void
playSlot
();
signals:
void
media
Player
Ready
();
void
mediaReady
();
};
#endif // MEDIA_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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