Playing stream video using intent?

susu

Well-Known Member
Licensed User
Longtime User
Because B4A doesn't support playing stream video (like rtsp://111.22.333.444)
so I want to play it by calling intent. Anyone know how please help, thank you :D
 

moster67

Expert
Licensed User
Longtime User
I have written a streaming-application and I can assure that there are lots of things to take into consideration, especially using the rtsp-protocol and 3G (in LocalLAN there shouldn't be any problems).

In any case, I wrote a small library using intent. Part of the library-code is:

B4X:
public static Intent anyPlayer(String DestAddr)
{
 Uri uri = Uri.parse(DestAddr.toString());
 Intent i = new Intent("android.intent.action.VIEW");
 i.setDataAndType(uri, "video/*");
 return i; 
}

I believe that today there is no need for this library since you can do this in B4A using the phone-library (the Intent object). Don't ask me how because I haven't played with it :)

Above code will permit the end-user to select which player to use for streaming (internal default application or any other installed application on the device which can handle video-streaming such as vPlayer, RockPlayer).

Hope this will help you.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Thanks moster67, I tried this code but it didn't work

Dim i As Intent
i.Initialize(i.ACTION_VIEW, "rtsp://111.222.333.4444")
i.SetType("video/*")
StartActivity(i)

This code is ok :D

Dim i As Intent
i.Initialize(i.ACTION_VIEW, "rtsp://111.222.333.4444")
StartActivity(i)
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I used this code to open video by calling intent:

B4X:
Dim i As Intent
i.Initialize(i.ACTION_VIEW, "rtsp://111.222.333.4444")
StartActivity(i)

But there's no option "Use by default for this action". How can I get it? :sign0085:

attachment.php
 

Attachments

  • option.jpg
    option.jpg
    20 KB · Views: 4,913
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I haven't found any information that explains when this option appears and when it doesn't.

Sorry for my unclear question. Screenshot on the left is my app, on the right is other's app. I want to have the option like this.

Did you try wrapping the intent with an intent chooser (with WrapAsIntentChooser)?

Yes, I use this code:
i.WrapAsIntentChooser("Open with...")

If there is a specific application that you want to launch then you can launch it explicitly by setting the component value.

Can you give me the code? In this case, I want to open streaming video using Android's internal video player.

Ps: Do you have plan to add some kind of streaming/online video audio player?

Thank you so much.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Did you try sending the intent without wrapping it as an intent chooser?
Can you give me the code?
This code opens the YouTube app: Intent1.SetComponent("com.google.android.youtube/.HomeActivity")

Do you have plan to add some kind of streaming/online video audio player?
I guess that it will be available in the future.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Alternatively, if you indicate in your application that the user must install a specific player, then you can do something similar:

B4X:
public static Intent PlayvPlayer(String DestAddr)
{
 String Package="me.abitno.vplayer";
 Uri uri = Uri.parse(DestAddr.toString());
 Intent i = new Intent("android.intent.action.VIEW");
 i.setPackage(Package);
 i.setDataAndType(uri, "video/*");
 return i;       
}

This will open automatically the player you set in the package-name.

You need to find out the package-name of the player concerned and then you call it in the intent. In your B4A-code, you need to handle the error in case the player is not present.

I don't know if above intent works with the B4A-phone intent object.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Did you try sending the intent without wrapping it as an intent chooser?

Oh yeah, it's ok now. Thank you Erel.

@Moster67: Thank you for your suggestion but that is too complicated to me :(
I can wait until B4A supports streaming video.
 
Upvote 0

luke2012

Well-Known Member
Licensed User
Longtime User
Could be also done using this statement before the call to "StartActivity" ?

i.setPackage("com.google.android.youtube");
 
Upvote 0
Top