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
 

Cynikal

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

URL:=???


What I would do personally is...

Write a PHP script that handled a redirect with some passwords in it...

Example:

http://www.pathtoyoursite.com/some/nested/directory/loadsong.phpTitle=This Song&Artist=That One Guy&AuthCode=SomethingGoesHere&PhoneMAC=themac


Once you goto said thing, have it do a redirect to the song, or just give the location to the public url of the song.



In your PHP script i'd have it log what files were listened to, and when..and by who.
 
Upvote 0

ericvanderhoeven

Member
Licensed User
Longtime User
local footage

@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).

Hi Moster67,

very VERY interesting stuff. Can you replace a streaming URL with a local reference (to a file already present on local memory) and if so, how?

In your library, one needs to feed it a single string. In the standard videoview library, one needs to give it 2 strings (path, filename)

Taken from your library B4A file =

StreamAddress="http://www.cybertechmedia.com/samples/johngreene.wmv"

PackageName="me.abitno.vplayer" 'this is vPlayer - you need to find out package-name of the player you want to use

StartActivity(myVideoPlayer.PlaySelectedPlayer(StreamAddress,PackageName))

Thanks,

Eric
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Eric,

My wrapper-library should work fine with local files as well. This worked for me calling a mp4-file named "fringe.mp4" stored on my internal SD-card on my Samsung Galaxy S3:

B4X:
Sub Stream_Click

'use predefined player
   Dim myroot As String
   Dim StreamAddress, PackageName As String
   myroot=File.DirRootExternal
   StreamAddress="file://" & myroot & "/fringe.mp4"
   PackageName="me.abitno.vplayer.t" 'this is packagename of latest vplayer
   'PackageName="org.videolan.vlc.betav7neon" 'this is VLC-player using neon-version installed on my device

   StartActivity(myVideoPlayer.PlaySelectedPlayer(StreamAddress,PackageName))
   
End Sub

If you include your own video-file in your apk, it will probably end up in your app's asset-folder. In this case, I don't think you can play it and you need to first copy the file to a folder which can be accessed, perhaps on the SD-card. Then it should work. You need to test and see for yourself.

As a side-note, you probably don't need my wrapper-library any longer since I wrote it a long time ago when certain functionaility was not availble in B4A or perhaps because I was unsure how to use itents (I don't remember the reason now).

With help of Agraham's excellent Reflection-library you can probably obtain the same result using these two small B4A code-snippets:

B4X:
Sub Stream_Click

   Dim myInt As Intent
   Dim myroot As String
   myroot=File.DirRootExternal

   myInt.Initialize(myInt.ACTION_VIEW,"file://" & myroot & "/fringe.mp4")

   SetPackage(myInt,"me.abitno.vplayer.t")
   myInt.SetType("video/*")

   StartActivity(myInt)
End Sub

Sub SetPackage(i As Intent, PackageName As String)
    'couldn't find SetPackage-method among B4A's default intents. We therefore use Agraham's reflection-library to add it.
   Dim rf As Reflector
    rf.Target = i
    rf.RunMethod2("setPackage", PackageName, "java.lang.String")
End Sub

Good luck!
 
Upvote 0
Top