mrmaffen / vlc-android-sdk

VLC Android SDK pushed to Maven Central. Primarily used in project tomahawk-android.
792 stars 244 forks source link

Where is How-To Doc? #75

Open chengxinwen-vinci opened 7 years ago

chengxinwen-vinci commented 7 years ago

Sorry, I'm new to LibVLC for maintain a existing project which uses it.

I replace old libvlcjni.so and source code with your latest sdk (v2.0.6), but I can't find how-to document from this git repro, and I'm not clear how to use this.

screen shot 2017-03-24 at 10 26 19

For example, there's no VLCInstance and LibVlcException in your sdk, so I don't know how to start to create a new instance of VLC player.

Would you please help? Thanks a lot in advance!

rainboy93 commented 7 years ago

Hi, You can try this https://github.com/dariobanfi/multiplevlc worked for me

chengxinwen-vinci commented 7 years ago

Thanks @rainboy93 , but it's not what I want :)

nguyenhoanglam commented 7 years ago

Try this:


import org.videolan.libvlc.IVLCVout;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaPlayer

    private void createPlayer(String url) {
        try {
            ArrayList<String> options = new ArrayList<>();
            options.add("--aout=opensles");
            options.add("--audio-time-stretch");
            options.add("--http-reconnect");
            options.add("--network-caching=" + 6 * 1000);
            options.add("-vvv");
            mLibVLC = new LibVLC(getContext(), options);

            mMediaPlayer = new MediaPlayer(mLibVLC);
            mMediaPlayer.setEventListener(mPlayerListener);

            final IVLCVout vout = mMediaPlayer.getVLCVout();
            vout.setVideoView(mSurfaceView);
            vout.attachViews();

            Media media = new Media(mLibVLC, Uri.parse(url));
            mMediaPlayer.setMedia(media);
            mMediaPlayer.play();
        } catch (Exception e) {
            // show error log
        }
    }
chengxinwen-vinci commented 7 years ago

Great thanks to @nguyenhoanglam ! I'll try it soon, and I have another question, would you please help? https://code.videolan.org/videolan/vlc-android/issues/239 , thanks in advance!

chengxinwen-vinci commented 7 years ago

Hi @nguyenhoanglam , in your way, media player can't play music, can you play "https://d29r7idq0wxsiz.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=219189184&c=cf&f=ts&t=10&bl=256k&s=true&e1=1490338800000&e2=1490339700000&v=V2&h=46dc257a18fa1d6044c09b2c43a573e1830a153c829bed3b1652b450e54ee3db" by url way?

I add permission for internet accessibility and write external storage, and this song won't be play.

03-24 15:07:45.860 12895-12895/com.vinci.libvlcdevlab W/MainActivity: MediaChanged
03-24 15:07:45.890 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":0,"arg2":0.0,"type":256}
03-24 15:07:45.890 12895-12895/com.vinci.libvlcdevlab W/MainActivity: Opening
03-24 15:07:45.890 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":0,"arg2":0.0,"type":258}
03-24 15:07:45.890 12895-12895/com.vinci.libvlcdevlab W/MainActivity: Buffering
03-24 15:07:45.890 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":0,"arg2":0.0,"type":259}
03-24 15:07:50.790 12895-12895/com.vinci.libvlcdevlab W/MainActivity: SeekableChanged
03-24 15:07:50.800 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":1,"arg2":0.0,"type":269}
03-24 15:07:50.800 12895-12895/com.vinci.libvlcdevlab W/MainActivity: PausableChanged
03-24 15:07:50.800 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":1,"arg2":0.0,"type":270}
03-24 15:07:50.800 12895-12895/com.vinci.libvlcdevlab W/MainActivity: Playing
03-24 15:07:50.800 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":0,"arg2":0.0,"type":260}
03-24 15:07:52.540 12895-12895/com.vinci.libvlcdevlab W/MainActivity: EndReached
03-24 15:07:52.540 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":0,"arg2":0.0,"type":265}
03-24 15:07:52.540 12895-12895/com.vinci.libvlcdevlab W/MainActivity: Stopped
03-24 15:07:52.540 12895-12895/com.vinci.libvlcdevlab W/MainActivity: event: {"arg1":0,"arg2":0.0,"type":262}
nguyenhoanglam commented 7 years ago

I've tested your url by VLC Player and it can not be streamed. Maybe it's an invalid url.

chengxinwen-vinci commented 7 years ago

@nguyenhoanglam , it's an usable url, you can input it into address bar of web browser, and download a media file, and you can open and play it by VLC Player for OS X.

nguyenhoanglam commented 7 years ago

I paste your url in web browser and see "access was denied" error.

chengxinwen-vinci commented 7 years ago

@nguyenhoanglam , url has time limitation. Would you please try this one (https://d29r7idq0wxsiz.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=233011633&c=cf&f=ts&t=10&bl=256k&s=true&e1=1490344200000&e2=1490345100000&v=V2&h=8d6b63cf72e48e1b4f43a617b9e69b3e7b29b4401a85249f6afb2e14b33b1acf), I just download it from web, and can play it by VLC Player for OS X, but still can't play in LibVLC.

screen shot 2017-03-24 at 15 21 42
chengxinwen-vinci commented 7 years ago

Does LibVLC have any property to set for accessing Amazon music stream? I didn't find out.

chengxinwen-vinci commented 7 years ago

If I use android.media.MediaPlayer instance for playing the same url, it works.

liauli commented 7 years ago

I also have a same issue. It works well for a normal m3u8 and mp4 links. but when I tried m3u8 wrapped mp4 links, it can't be played. the same link is also not working on offical VLC player app on android but works well on Windows VLC player. I am using Libvlc 2.0.6

however, when I tried to play it in 3.0.0 and 1.0.1 i found no problem on playing that link but isn't the library kinda outdated ?

I think it is a same problem with yours! Haven't found any solution so far =(

pandyasagar commented 6 years ago

@nguyenhoanglam
can I play video from local storage with your code ?