Found way to stream video but will this method waste devices internal memory?

mistermentality

Active Member
Licensed User
Longtime User
I have been working on an app to search for and stream videos from archive.org and am using this code

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

where URL is the url of an mpeg4 video file.

It plays the video without waiting for it to download but by doing it this way does it mean that the entire video would be downloaded and saved to the devices internal memory while it plays, which would cause problems on low ram devices such as phones?

If it does I would have to find a way to save the linked to video to sd card and read it from there but as I do not know whether I need to I thought I would ask if the above method will use up the internal memory of a device?

Dave
 

LittleEddie

Member
Licensed User
Longtime User
Well, it should be opening the Media player are something like that and playing the video. Your App is not playing the video so you don't need to worry about the memory.


Ed
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
Thank you for the quick reply

Unfortunately the only problem I have now is that I cannot force it to open with a specific player and the default player will not play some videos. Tried changing it to open with the MixZing app by doing:

B4X:
i.Initialize(i.ACTION_VIEW, URL)
   i.SetType("video/*")
   i.SetComponent("com.mixzing.basic")
   StartActivity(i)

But it doesn't work nor does trying to get it to offer a choice of any installed players, but the default plays about quarter of the videos so it's a start and your reply has helped a lot so thank you, again :)

Dave
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you turn off the log filter and send an intent that you know will open a particular app or at least offer the app in a chooser, then choose the app you want you should see the component name that you need to set to call it directly in the log.

It worked for HTC mail at least, so I hope it will show you what you need.

Steve
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
If you turn off the log filter and send an intent that you know will open a particular app or at least offer the app in a chooser, then choose the app you want you should see the component name that you need to set to call it directly in the log.

It worked for HTC mail at least, so I hope it will show you what you need.

Steve

I tried two different routines to do that, or I think they should have worked, but neither did :(

One was:
B4X:
i.Initialize(i.ACTION_VIEW, URL)
   i.SetType("video/*")
   i.SetComponent("com.mixzing.basic")
   StartActivity(i)

and the other was:
B4X:
i.Initialize(i.ACTION_VIEW, URL)
   i.SetType("video/*")
   i.WrapAsIntentChooser("Open with....")
   StartActivity(i)

But neither changes anything.I know the name is correct for MixZing app as I checked it's documentation so am puzzled as to why neither method works.

I shall keep trying though :)

Dave
 
Upvote 0

Cor

Active Member
Licensed User
Longtime User
Is it possible to load mp3 from a password protected site( which i have)
for my mp3 files

URL:=???

B4X:
Dim i As Intent
        i.Initialize(i.ACTION_VIEW, URL)
   i.SetType("video/*")
   StartActivity(i)
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@mistermentality

Some time ago, before intent was supported in B4A, I wrote a small library to start streaming of a video using a certain application. The java-code of the library is as follows:

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;       
}

where Package is the name of the app I want to open for video-streaming.

Maybe this can help you otherwise I can pass you on a copy of the library
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
@mistermentality

Some time ago, before intent was supported in B4A, I wrote a small library to start streaming of a video using a certain application. The java-code of the library is as follows:

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;       
}

where Package is the name of the app I want to open for video-streaming.

Maybe this can help you otherwise I can pass you on a copy of the library

I have eclipse but no idea how I would that code as I find eclipse difficult, would I just load it in and compile to get the library?

@Cor Yes you should be able to change the video bit of the code in the original post for something like "Audio/mp3", the URL is just a string variable which I use to hold the url address of the current video file to play so you would swap that with your mp3 files location.

You would have to send a http request that sent the password or username I think, but I know it is possible and that you can adapt the code for music files.

Dave
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@mistermentality

Try the library attached. I am posting also an example project.

Clicking on one of the buttons should permit user to select a videoplayer to use while the other button opens a predefined videoplayer (in the example, I am using vPlayer but you can insert in the code the package-name of the videoplayer you would like to use).

I have eclipse but no idea how I would that code as I find eclipse difficult, would I just load it in and compile to get the library?Dave
 

Attachments

  • VideoPlayer.zip
    5.8 KB · Views: 491
  • VideoPlayeLibrary.zip
    2 KB · Views: 468
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
@mistermentality

Try the library attached. I am posting also an example project..

Thank you for the help, but using the library the first example code works great however the one that lets you specify the package gives this error:

"StartActivity(myVideoPlayer.PlaySelectedPlayer(YRL,PackageName)) android.content.ActivityNotFoundException: No Activity found to handle Intent"

I am using this code:
B4X:
PackageName="com.mixzing.basic"
   StartActivity(myVideoPlayer.PlaySelectedPlayer(URL,PackageName))

and the package name is correct. I'm new to Android programming so maybe I am wrong but is this telling me it cannot find the mixzing app as I have verified the name and tried with several different video players?

At the end of the error message it adds "flg=0x20000" if that helps.

Dave

PS your help is very appreciated, thank you :)
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@mistermentality

You must make sure to use a player that supports streaming. I tried mixzing as well and it does not work. Mixzing does not even appear among the players to use for streaming.

I tried another player which I know supports streaming, which is RockPlayer Lite, and by giving its packagename as a parameter in the library, Rockplayer is launched and streaming starts. Other players, for instance, that support Streaming are vPlayer and mVideoPlayer.
 
Last edited:
Upvote 0

moster67

Expert
Licensed User
Longtime User
@mistermentality

Just some notes:
1) while certain players do support streaming from within their app, they may not have registered themselves as an application capable of streaming and Android OS will not recognize it as a player that support streaming. If you can see the player in the list of available players (using the option in my library where you do not indicate packagename), then it means that Android OS knows it can handle streaming and you can use its packagename.

2) Android is still very poor what regards video-streaming and in particular as to video-codecs supported. Some codecs are supported only when playing a videofile on SD-card while they are not supported in streaming-mode. Players like vPlayer and Rockplayer have implemented the FFMPEG-library and they support most video-codecs out there and also support hardware-decoding.
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
Thank you, you were right and Rockplayer Lite did work so it was the video player apps that were at fault. Have you thought of including your library in the libraries section of the forum as it's very helpful and has certainly helped me out :)

Dave
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Glad it worked.

No, I won't put it in the library-section. The library is just made of two code-snippets. You could probably achieve the same result using the Phone-library and its Intent-object.

There was a similar issue like yours in this thread:

http://www.b4x.com/forum/basic4android-updates-questions/7771-playing-stream-video-using-intent.html

I only believe that certain objects should be explained a bit more. The intent-object is probaby very powerful but there's not much documentation about it (except for official documentation on Android Developer). I would surely like to see a tutorial about using the Intent-object along with some examples. This would help enormously.
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
The intent-object is probaby very powerful but there's not much documentation about it (except for official documentation on Android Developer). I would surely like to see a tutorial about using the Intent-object along with some examples. This would help enormously.

Thanks again for the help.

I haven't programmed for years and then only in old school basic (as in BBC type basic) so any tutorials on the use of Intent would be brilliant as it does look very useful but as I am a newb rediscovering programming I agree that more examples would be very handy :)

B4A is brilliant and has enabled me, someone who only used the early forms of Basic, to jump right in and straight away produce apps that do what I want how I want them to. Have to admit it's a great language and hopefully more tutorials will come along later.

Dave
 
Upvote 0

ZJP

Active Member
Licensed User
Longtime User
Tx Moster67. Works very well with MoboPlayer : https://market.android.com/details?id=com.clov4r.android.nil :sign0060:

JP
B4X:
' Based on Moster67 lib and source
    
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim myVideoPlayer As VideoPlayer
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("VideoPlayer")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub Button1_Click
   'user select which player to use
   Dim StreamAddress As String
   StreamAddress="http://www.davewomach.com/Video/Tiger2.wmv" '
   StartActivity(myVideoPlayer.PlayAnyPlayer(StreamAddress))
End Sub

Sub Button2_Click
'use predefined player
   Dim StreamAddress, PackageName As String
   StreamAddress="http://www.peavynet.com/video1/WarnerC.wmv"
   PackageName="com.clov4r.android.nil" 'MoboPlayer
   StartActivity(myVideoPlayer.PlaySelectedPlayer(StreamAddress,PackageName))
End Sub
 
Last edited:
Upvote 0

alexb

Member
Licensed User
Longtime User
Videoplayer not in fullscreen possible?

:sign0098:Tx Moster67 for this nice library and example! - Unbelievable how easy it is to stream a video this way.

Is it possible to show the video not in fullscreen but only in a portion of the available screen? For example attach the video to some panel and the video would only be displayed in the area of the panel? Why? I would love to create some picture that looks like an old style TV and display then the video inside that old TV frame.

Any ideas?

Thanks, alexb
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I doubt there is a way to show the video within your app the way you want. My library is meant to open an external player and I don't think you can incorporate that player within your app.

To obtain what you want, I guess we need B4A to support video-streaming but hey, audio-streaming was recently added so perhaps video-streaming will be added later on by Erel.

:sign0098:Tx Moster67 for this nice library and example! - Unbelievable how easy it is to stream a video this way.

Is it possible to show the video not in fullscreen but only in a portion of the available screen? For example attach the video to some panel and the video would only be displayed in the area of the panel? Why? I would love to create some picture that looks like an old style TV and display then the video inside that old TV frame.

Any ideas?

Thanks, alexb
 
Upvote 0
Top