devkanro / Meta.Vlc

Meta.Vlc is a LibVlc wrapper for WPF.
Do What The F*ck You Want To Public License
276 stars 85 forks source link

have any function for callback from rtsp? #67

Closed seekerquoc closed 8 years ago

seekerquoc commented 8 years ago

I need to get frame when play with rtsp but i dont find any function for this?

Can you help me?

Thanks

devkanro commented 8 years ago

Get frame? If you want get the raw image data, you can use the VideoSource property. If you want use a callback when display a frame, it is not support now, but it is easy to do it. Or some callback when you load a rstp stream?

seekerquoc commented 8 years ago

some callback when you load a rstp stream?

I need to use this for get frame and convert it to bitmap,

Can you show me this?

Thanks

devkanro commented 8 years ago

Ummm...Maybe you can use StateChanged event. When you load a media, player's state will be changed.

NothingSpecial -> Opening -> Buffering -> Playing.

seekerquoc commented 8 years ago

can you show me code for this? i dont know how use statechanged function on sample wpf :(

devkanro commented 8 years ago

Ummm...I have no PC now, I give you some sample next week.

devkanro commented 8 years ago
VlcPlayer vlcPlayer = new VlcPlayer();
vlcPlayer.StateChanged += (o, args) =>
{
    switch (args.Value)
    {
        case MediaState.NothingSpecial:
            // VlcPlayer has initialized.
            break;
        case MediaState.Buffering:
            // Meida is buffering.
            break;
        case MediaState.Opening:
            // Meida is opening.
            break;
        case MediaState.Playing:
            // Meida is playing.
            break;
        case MediaState.Paused:
            // Meida is paused.
            break;
        case MediaState.Stopped:
            // Meida is stopped.
            break;
        case MediaState.Ended:
            // Meida is ended.
            break;
        case MediaState.Error:
            // Some error has been encountered.
            break;
    }
};

If you want to know the media is a rstp stream media or not. You can check the vlcPlayer.VlcMediaPlayer.Media.Mrl.

Uri mediaMrl = null;
if (Uri.TryCreate(vlcPlayer.VlcMediaPlayer.Media.Mrl, UriKind.Absolute, out mediaMrl))
{
    switch (mediaMrl.Scheme.ToLower())
    {
        case "rstp":
            // It is a RSTP stream media.
            break;
        case "rtp":
            // It is a RTP stream media.
            break;
        case "udp":
            // It is a UDP stream media.
            break;
        case "tcp":
            // It is a TCP stream media.
            break;
        case "http":
            // It is a HTTP stream media.
            break;
        case "https":
            // It is a HTTPS stream media.
            break;
        case "file":
            // It is a local media.
            break;
        default:
            //Other meida type.
            break;
    }
}
seekerquoc commented 8 years ago

Hi im using videosource for get frame and use timepicker for control this