iOS Video

Hi all,

Curious to know if there is a way to load and Play a video on a ios Device?

Adam

[quote=163021:@adam sion]Curious to know if there is a way to load and Play a video on a ios Device?
[/quote]

The HTMLViewer for standard formats ?

Has anyone done this?

I have not been able to connect htmlviewer to a QuickTime. The suggestion is made elsewhere to drag files to be used by htmlviewer directly into the project. For me, they do not take, although I do it all the time for desktop.

There is an example view of this in my iOSKit.
https://github.com/kingj5/iOSKit

thank you jason. this definitely feels like the right track. i can go in to your “player” code and substitute a reference to one of my movies and it plays it. very nice.

Dim MovieFolderItem As FolderItem
MovieFolderItem = SpecialFolder.GetResource( “Truth02_iOS.mov” )

Dim MyMediaURL As Foundation.NSURL
MYmediaURL = mediaURL.FileURLWithPath( MovieFolderItem.Path )

player = new Extensions.MPMoviePlayerController(MYmediaURL)
player.prepareToPlay

etc.

Now i am stuck understanding how i bring that functionality into my own app. do i drag in the whole iOSkit-Master folder? i am hoping to associate code with various views that will play movies on that view. i am really hoping i can find a way to add a button to each such view that will allow the user to click through a sequence of movies on that view.

Hi James,
If you open up the example project you can then copy and paste the entire Modules folder into your app and everything will be accessible so you can use the exact code that you have above. If for some reason you do not want to include all of the modules and only the ones that are important to your app then you can delete the unnecessary ones, but you will definitely have to keep the Extensions, Foundation, and UIKit modules.

This isn’t super important but there is a helpful constructor for the Foundation.NSURL class which allows you to pass a xojo.io.folderitem so you do not have to use one of the of the shared methods to create the NSURL object as you are doing now, i.e.:

[code]Dim MovieFolderItem As FolderItem
MovieFolderItem = SpecialFolder.GetResource( “Truth02_iOS.mov” )

Dim MyMediaURL As new Foundation.NSURL(MovieFolderItem) // <— convenience constructor

player = new Extensions.MPMoviePlayerController(MYmediaURL)
player.prepareToPlay[/code]
Adding code to click through a series of movies on the view shouldn’t be too hard at all. I’m not sure how you will want to approach it, but you could load all of the file names into a iOSTable, and the use the Action event to retrieve the proper folderitem and create the player, or even just use an array and have a button advance through the array and load the proper movie.

If you have any questions, just ask.
Jason

okay, i am getting closer. i have been getting a blizzard of errors when i dragged in the iOS-Kit modules. it turns out that, for me, they fight with some iOS-Lib stuff i have been using to keep old desktop syntax going. when i delete the iOS-Lib stuff, iOS-Kit becomes happy. meanwhile iOS-Lib seems to be changing as we speak, so i think i am best off just #IF’ing around the couple dozen lines that iOS-Lib was keeping alive, then trying iOS-Kit again. i will let you know how it goes. thanks again jason.

I just tried a very simple code with an HTMLViewer :

dim f as FolderItem = SpecialFolder.GetResource("spacetestSMALL_512kb.mp4") me.LoadURL(f.URLPath)

The video file was dragged into the project.

Works like a charm :slight_smile:

Okay, I have eliminated the cross-talk with ios-lib and can now bring .mov files into the resource folder and play them from there within my iPad app. Very sweet.

Where I am stuck is in positioning the player. It seems to center in the upper left, showing only the lower right quadrant. Is there a way to control the positioning? My movies are 1024x570 so I have room below for a button or two. The player seems to pad them out to screen size with black bars top and bottom. Is there control over that?

Anyhow, this is great progress. iOS-kit is amazing.

James

Hi James,
Thanks for the kind words.
In the original example I actually used the wrong declare (I set the bounds, not the frame) which caused the weird positioning you are seeing. Here is the example view redone to use the right declare as well as showing how to position it where you want on a view. You will just have to change the size of the canvas to match your desired size.

https://www.dropbox.com/s/o9fsucr21tum43e/record%20play%20video%20v2.xojo_binary_project?dl=0

Hopefully this helps,
Jason

Hello Jason.

I now have my 28 quick times running in iOS (just the simulator so far.) I am very grateful.

The one issue I have is that each animation is preceded by a flash of black canvas. Since the view is just sliding In as the first animation starts, the black flash is largely masked by the motion. However, I use a button to start up each of the next ones; here the black blink is very noticeable. Have you any thoughts on a possible workaround?

I have tried the player call in a function and also in the paint event of the canvas. They both seem to do the same.

James