Java Code Examples for org.videolan.libvlc.Media#release()

The following examples show how to use org.videolan.libvlc.Media#release() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Expand the current media.
 * @return the index of the media was expanded, and -1 if no media was expanded
 */
@MainThread
public int expand() {
    final Media media = mMediaPlayer.getMedia();
    if (media == null)
        return -1;
    final MediaList ml = media.subItems();
    media.release();
    int ret;

    if (ml.getCount() > 0) {
        mMediaList.remove(mCurrentIndex);
        for (int i = ml.getCount() - 1; i >= 0; --i) {
            final Media child = ml.getMediaAt(i);
            child.parse();
            mMediaList.insert(mCurrentIndex, new MediaWrapper(child));
            child.release();
        }
        ret = 0;
    } else {
        ret = -1;
    }
    ml.release();
    return ret;
}
 
Example 2
Source File: MediaBrowser.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Browse to the specified local path starting with '/'.
 *
 * @param path
 * @param flags see {@link MediaBrowser.Flag}
 */
@MainThread
public void browse(String path, int flags) {
    final Media media = new Media(mLibVlc, path);
    browse(media, flags);
    media.release();
}
 
Example 3
Source File: MediaBrowser.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Browse to the specified local path starting with '/'.
 *
 * @param path
 * @param flags see {@link MediaBrowser.Flag}
 */
@MainThread
public void browse(String path, int flags) {
    final Media media = new Media(mLibVlc, path);
    browse(media, flags);
    media.release();
}
 
Example 4
Source File: VLCUtil.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a media thumbnail.
 * @return a bytearray with the RGBA thumbnail data inside.
 */
public static byte[] getThumbnail(LibVLC libVLC, Uri uri, int i_width, int i_height) {
    /* dvd thumbnails can work only with dvdsimple demux */
    if (uri.getLastPathSegment().endsWith(".iso"))
        uri = Uri.parse("dvdsimple://" + uri.getEncodedPath());
    final Media media = new Media(libVLC, uri);
    byte[] bytes = getThumbnail(media, i_width, i_height);
    media.release();
    return bytes;
}
 
Example 5
Source File: MediaBrowser.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Browse to the specified uri.
 *
 * @param uri
 * @param flags see {@link Flag}
 */
@MainThread
public void browse(Uri uri, int flags) {
    final Media media = new Media(mLibVlc, uri);
    browse(media, flags);
    media.release();
}
 
Example 6
Source File: Dumper.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 *
 * @param uri      the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example 7
Source File: MediaWrapper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
public void updateMeta(MediaPlayer mediaPlayer) {
    if (!TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mDisplayTitle))
        mDisplayTitle = mTitle;
    final Media media = mediaPlayer.getMedia();
    if (media == null)
        return;
    updateMeta(media);
    media.release();
}
 
Example 8
Source File: Dumper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example 9
Source File: VLCUtil.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Get a media thumbnail.
 * @return a bytearray with the RGBA thumbnail data inside.
 */
public static byte[] getThumbnail(LibVLC libVLC, Uri uri, int i_width, int i_height) {
    /* dvd thumbnails can work only with dvdsimple demux */
    if (uri.getLastPathSegment().endsWith(".iso"))
        uri = Uri.parse("dvdsimple://" + uri.getEncodedPath());
    final Media media = new Media(libVLC, uri);
    byte[] bytes = getThumbnail(media, i_width, i_height);
    media.release();
    return bytes;
}
 
Example 10
Source File: MediaBrowser.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Browse to the specified uri.
 *
 * @param uri
 * @param flags see {@link MediaBrowser.Flag}
 */
@MainThread
public void browse(Uri uri, int flags) {
    final Media media = new Media(mLibVlc, uri);
    browse(media, flags);
    media.release();
}
 
Example 11
Source File: MediaBrowser.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Browse to the specified local path starting with '/'.
 *
 * @param path
 * @param flags see {@link Flag}
 */
@MainThread
public void browse(String path, int flags) {
    final Media media = new Media(mLibVlc, path);
    browse(media, flags);
    media.release();
}
 
Example 12
Source File: MediaWrapper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
public void updateMeta(MediaPlayer mediaPlayer) {
    if (!TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mDisplayTitle))
        mDisplayTitle = mTitle;
    final Media media = mediaPlayer.getMedia();
    if (media == null)
        return;
    updateMeta(media);
    media.release();
}
 
Example 13
Source File: VLCUtil.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Get a media thumbnail.
 * @return a bytearray with the RGBA thumbnail data inside.
 */
public static byte[] getThumbnail(LibVLC libVLC, Uri uri, int i_width, int i_height) {
    /* dvd thumbnails can work only with dvdsimple demux */
    if (uri.getLastPathSegment().endsWith(".iso"))
        uri = Uri.parse("dvdsimple://" + uri.getEncodedPath());
    final Media media = new Media(libVLC, uri);
    byte[] bytes = getThumbnail(media, i_width, i_height);
    media.release();
    return bytes;
}
 
Example 14
Source File: MediaBrowser.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Browse to the specified uri.
 *
 * @param uri
 * @param flags see {@link MediaBrowser.Flag}
 */
@MainThread
public void browse(Uri uri, int flags) {
    final Media media = new Media(mLibVlc, uri);
    browse(media, flags);
    media.release();
}
 
Example 15
Source File: MainActivity.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    final IVLCVout vlcVout = mMediaPlayer.getVLCVout();
    if (mVideoSurface != null) {
        vlcVout.setVideoView(mVideoSurface);
        if (mSubtitlesSurface != null)
            vlcVout.setSubtitlesView(mSubtitlesSurface);
    } else
        vlcVout.setVideoView(mVideoTexture);
    vlcVout.attachViews(this);

    Media media = new Media(mLibVLC, Uri.parse(SAMPLE_URL));
    mMediaPlayer.setMedia(media);
    media.release();
    mMediaPlayer.play();

    if (mOnLayoutChangeListener == null) {
        mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
            private final Runnable mRunnable = new Runnable() {
                @Override
                public void run() {
                    updateVideoSurfaces();
                }
            };

            @Override
            public void onLayoutChange(View v, int left, int top, int right,
                                       int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
                    mHandler.removeCallbacks(mRunnable);
                    mHandler.post(mRunnable);
                }
            }
        };
    }
    mVideoSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
}
 
Example 16
Source File: Dumper.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example 17
Source File: VLCUtil.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get a media thumbnail.
 * @return a bytearray with the RGBA thumbnail data inside.
 */
public static byte[] getThumbnail(LibVLC libVLC, Uri uri, int i_width, int i_height) {
    /* dvd thumbnails can work only with dvdsimple demux */
    if (uri.getLastPathSegment().endsWith(".iso"))
        uri = Uri.parse("dvdsimple://" + uri.getEncodedPath());
    final Media media = new Media(libVLC, uri);
    byte[] bytes = getThumbnail(media, i_width, i_height);
    media.release();
    return bytes;
}
 
Example 18
Source File: MediaBrowser.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Browse to the specified local path starting with '/'.
 *
 * @param path
 */
public synchronized void browse(String path) {
    final Media media = new Media(mLibVlc, path);
    browse(media);
    media.release();
}
 
Example 19
Source File: Dumper.java    From vlc-example-streamplayer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example 20
Source File: MediaBrowser.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Browse to the specified uri.
 *
 * @param uri
 */
public synchronized void browse(Uri uri) {
    final Media media = new Media(mLibVlc, uri);
    browse(media);
    media.release();
}