Embed video or play video from URL possible?

Monkey Forums/Monkey Programming/Embed video or play video from URL possible?

Difference(Posted 2011) [#1]
I'd like to embed a video in my app, mainly for iPhone and Andriod.

I'd also like to know if there is any way to stream video and sound from the net.

Is any of this possible in Monkey yet?


xzess(Posted 2011) [#2]
Well on iOS it should be possible by adding the MediaPlayer Framework (XCode)
to the Monkey Target (if it is not already)





I did this for imonk some days ago, but very untested yet:

mplayer.monkey
Import "native.cpp"  'contains native cpp code

Extern

Function MPlayerStreamVideo(Url$)
Function MPlayerPlayVideo(Filename$)


native.cpp

#import <MediaPlayer/MediaPlayer.h>

void MPlayerStreamVideo(String Url)
{
	// i.e. Url=http://www.yourwebsite.com/video.m4v
	NSString *StreamAdress = Url.ToNSString();
	MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:StreamAdress];
	[player play];
}

void MPlayerPlayVideo(String Filename)
{
// This Streams a M4v from inside your Monkey App (offline)
NSString *StrFilename = Filename.ToNSString()
NSString *path = [[NSBundle mainBundle] pathForResource:StrFilename ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:path];
 
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[player play];
}


Maybe you need to add the data folder ("data/") into the file url for MPlayerPlayVideo.

Greetz


Difference(Posted 2011) [#3]
Thanks xzess , I'll be following imonk progress!