4

I currently have an app that records a video and uploads it to my server. after uploading the video, the app gets a response that holds a URL to the flv stream to the file.

when I try to open the stream in the android default video player (Videos) nothing happens, but when I used a different app (BSPlayer), it played the video perfectly. however, there is no way to force opening one app from Intent.ACTION_VIEW. here is the code for the function that receives the response from the server:

@Override
protected void onResponseReceived(int requestType, int status, Object resp) {
    switch (requestType) {
    case CLIP_DETAILS: {
        if (status == RESPONSE_OK) {
            String token1 = ((ResponseObject_ClipDetails) resp).m_token1;
            String token2 = ((ResponseObject_ClipDetails) resp).m_token2;
            String url = getClipURL(token1, token2);

            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            i.setType("video/flv");
            startActivity(i);
        }

    }
        break;
    }
}

is there a way to show .flv videos in my android app?

thepoosh
  • 12,497
  • 15
  • 73
  • 132
  • 1
    You can change the code on server side, have it encode the videos into formats that Android [supports](http://developer.android.com/guide/appendix/media-formats.html). –  Jun 30 '12 at 08:22
  • I'm using a service that streams the video. It uses .flv only – thepoosh Jul 01 '12 at 10:11
  • Then basically you have to deal with third party libraries. –  Jul 01 '12 at 10:19

2 Answers2

5

You can use vitamio.

Media formats

Many audio and video codecs are packed into Vitamio beside the default media format built in Android platform, some of them are listed below.

  • divx/xvid
  • wmv
  • flv
  • ts
  • rmvb
  • mkv
  • mov
  • m4v
  • avi
  • mp4
  • 3gp

Vitamio SDK for Android developers

You can download the jar file to use with your project here. (Vitamio-SDK.7z)

For Android developers

Here is a demo project which uses the vitamio.jar. (Vitamio-Demo.7z)

Vitamio provides the similiar interfaces with Android default MediaPlayer framework. If you're using android.media.MediaPlayer in your project, just grab the vitamio.jar from above, then add it to your project's libs, and replace the import of android.media.MediaPlayer with io.vov.vitamio.MediaPlayer.

Besides the default interfaces from Android MediaPlayer, Vitamio provides more APIs, please refer the javadoc in the library.

yorkw
  • 40,926
  • 10
  • 117
  • 130
0

Actually, there is a way to force opening specific app.

This answer shows how to do that. https://stackoverflow.com/a/10035789/375929

Just find out BSPlayer's package name and use it to filter the apps to open your video. Of course, you'll also need to handle the case when there's no BSPlayer installed. I suggest using queryIntentActivities() - if it returns an empty list, tell user they need to install BSPlayer and launch the corresponding play store link.

Short of asking user to install a 3rd party app, you can also implement your own flv player via WebView, although you'll still need the user to have flash player (but that's somewhat different, everybody knows what flash player is, so it shouldn't be a problem to ask user to install it)

I found two tutorials on how to do that: Problem to load flv video in webview and http://www.synesthesia.it/playing-flash-flv-videos-in-android-applications

Community
  • 1
  • 1
Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59
  • the only problem is that I can't force my users to install a third-party application – thepoosh Jun 26 '12 at 08:38
  • Ok, there's one more trick - using WebView to play .flv, you'll have to implement the player in your app. I udpated the answer, check it out. – Ivan Bartsov Jun 26 '12 at 09:04