Playing movies on Mac?

BlitzMax Forums/MaxGUI Module/Playing movies on Mac?

Casaber(Posted 2016) [#1]
Is it possible to use standard BMax GUI commands and
create like a borderless/slim widget that neatly fits a youtubeclip, or a mp4/mp3?

I´m also wondering if it's possible to make it so that it fills up the whole screen and to make it as close to a normal fullscreen as humanly possible?


Casaber(Posted 2016) [#2]
This is what I got so far. Maybe I´m on the right track maybe not. I´m not sure.
Also I still haven't found how to fullscreen and scale things if this is the right way to do it.

EDIT
Got a bit closer, now going full screen using window and stretching the youtube content.
I have not yet checked what details you could adjust to make finer adjustments though e.g how to get away with scrollbars and such..

EDIT2
Am on the right track it seem, starting to look good.

SuperStrict
Import MaxGui.Drivers

' Get size of display
Local width:Int = GadgetWidth(Desktop())
Local height:Int = GadgetHeight(Desktop())

' Note that if I did mention pixels anywhere in code or comments 
' then it's good to know that I was working on a 1920 x 1080 display.

' Create GUI
Local window:TGadget , htmlview:TGadget
window = CreateWindow("Title",0,0,width,height,,15-1-2-4-8 | WINDOW_ACCEPTFILES) ' No titlebar

' 1 = titlebar
' 2 = resizable
' 4 = menu
' 8 = status bar
' 16 = tool window
' 32 = shape in client coordinates

htmlview = CreateHTMLView(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout htmlview,1,1,1,1

' Create HTML
Local file:TStream = WriteFile("temp.html")

' Current HTML
file.WriteLine "<html><head><style>"
file.WriteLine "body { overflow: hidden; }" ' "'body,html,iframe{margin:0;padding:0;}"
file.WriteLine "body { margin-top: 0px;margin-Right: 0px;margin-bottom: 0px;margin-Left: 0px}" '
file.WriteLine ".container {position: relative;width: 100%;height: 0;padding-bottom: 56.25%;}"
file.WriteLine ".video {position: absolute;top: 0; Left: 0; width: 100%; height: 100%;}"
file.WriteLine "</style></head><body>" ' <div class=~qcontainer~q> codegoeshere </div>

' Here was comments about miniumum what OSX (10.10.5) used for scrollbars. 23 seem to be the pixel height of the standard OSX menu at the top.
file.WriteLine "<iframe width='" + (width - 0) + "' height='" + (height - 23) + "' src=~qhttps://www.youtube.com/embed/LrKlO1Tr2IE?&theme=dark&autoplay=1&keyboard=1"
file.WriteLine "&autohide=1&modestbranding=1&fs=0&showinfo=0&rel=0&iv_load_policy=3~qframeborder=~q0~q></iframe>" ' &controls=0
file.WriteLine "</body></html>" ; file.Close ; Local htmlFile:String = (AppDir + "/temp.html").Replace("//","/")

' Show it
HtmlViewGo htmlview,htmlFile
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Wend



Casaber(Posted 2016) [#3]
This is what I get now. Everything's seem to be fullscreen, but there's 2 menus at the top (making the window offset downwards also), and there's the dock ontop of the window.

I would like to fix those issues aswell.
Or by any means, any other idea how to play youtube / mp4 / mp3 on BMax using the inbuild commandset are very welcome.

Of course I might just scale down the window in size just a wee bit to make it fit neatly on the desk and let the menus behave as a desk should.
But less clutter on the screen really helps to focus the attention. I know you could take away the Window title also but I save that for last.

EDIT
Got one of the menus out of the way, to do that I also needed to change 30 into 23 as things moved quiet abit up and revealed white space. 23 Made things perfect.
So the only thing now is that 23 pixels are lost vertically due to standard MacOS top bar, no pixels are lost horistonally, and then the dock is splashed ontop of everything.
The picture is the before picture, I don´t want to waste space it looks the same, just one less bar now. *Updated the original sourcecode accordingly*

One titlebar and one dock is all there is left to fix now. It might be that I just make the window smaller and fit it in the centre of everything. But I will try some more things first.




dw817(Posted 2016) [#4]
Casaber, I think I can get you some controls for your player, ones that are provided by default with your OS (Macintosh). Lemme sleep on it and I'll get back to this Friday (03-11-16).


dw817(Posted 2016) [#5]
Ok, I'm back, Casaber. Let's see what can be done here.

Nope. Apparently the 'browser' provided by BlitzMAX does not function the same way Firefox does. If you open an .Mp4 video in Firefox, it goes full-screen w a nice set of controls.

No such luck. Here is my model, does not work because instead BlitzMAX's 'explorer' asks to save the Mp4 file.



So ... it looks like the route you are going is the best. If you want to use your own custom player and controls without any Youtube interface or right-click menus, it can be done, I have done it, but it is not simple.


Casaber(Posted 2016) [#6]
Thanks for trying. I appriciate it. This was good though for me I needed to brush up my web skills. I did work for a company as a designer for few years so I know some HTML5.
At least to get this started. I just need to work it out, I guess sometimes next week I will do that.

I´m allright with having the mousepointer / dock and standard menubar of the OS. That's no problem at all, and the performance difference between fullscreen vs windowed mode is nice.
Now I got mp4, mp3 and youtube working and I got away with all menus without javascript. It was tricky but I'm happy with the results. On top of that I did a few things using javascript.
It was mainly details such as the dragging/deselection things like that. You don´t want those if you don't have to. If JS happen to be off that's basically all that happens.. you MAY accidently select an image or video and it gets a weird color, that's all, it still will be clean and debranded.

I just need to scale it properly using HW acc and also I need to check how to use youtube as a playlist (things like adding next prev and maybe even a shuffler programatically.
I'm thinking partly about to use true youtube playlists and I´m also thinking about using a single strand of video with lots of music in one stream and skip time.


Casaber(Posted 2016) [#7]
What does the 3 slashes mean in the code?


dw817(Posted 2016) [#8]
Hi Casaber. MAN did I get moving boxes done today ! All downstairs closet cleared.

The prefix "file:///" is a way Firefox (or really any browser) lets you load a LOCAL file into an Internet browser. While Firefox has a lovely media player interface if you load an Mp4 into it, the 'browser' provided by BlitzMAX does not.


Casaber(Posted 2016) [#9]
Hey there, I've done the same been sweating all day long moving boxes and whatnot, not me that's moving though just helping out.
I read about your move now.. I hope everything's goes well over there!?

About the slashes.. yu okay, that's really good to know how to handle local files I think I've done it before and forgot all about it.
I just downloaded the Youtube API docs, it's huge. The easy way would be I guess to just use their regular controls as they're good controls, there's no actual reason
really to use anything else. But I need to be able to know when a video or song is finished and such. I´m not sure what kind of flexibility awaits me.


Casaber(Posted 2016) [#10]
Could you draw ontop of a HTMLbox like this? Like putting a Canvas, some Buttons or something?
Or are layers something that does not exist in MaxGUI?


dw817(Posted 2016) [#11]
Since you're permitted to make a HTML, Casaber, I seem to remember from ... an HTML editor I used sometime ago, Frontpage Express, that you could make a movie player. Let me check my archives.


Casaber(Posted 2016) [#12]
That's allriight I just need a platform-independent way to play movies and mp3s, no need to make a full player out of it but it
would be fun !! I did a PIP (picture in picture) the other day wich rotates. But I need to code a mute function or you would hear both movies playing.

What I´ve understood only Linux lacks JS-support in Bmax HTMLVIEW so it's no problem for me whatsoever,
I could easly add Javascript if I wanted now which makes things much more fun.


Casaber(Posted 2016) [#13]
While doing this I discovered this could give so much more, all these things WINDOWS / APPLE - multiplatform:

- Play local/online audio/video (This is what I wanted at first)

- Stream youtube (audio/video in different configurations)

- View pdfs

- PRINT PDF JPG PNG HTML (other formats eg older formats such as DOCX would need tremendous work but I can live without them as I use html anyways I see that as superior (so does EPUB look at things aswell). And everything mentioned can be really accurately printed, using PRINT CSS.

- as a GUI instead of using direct GUIMAX elements which might seem an odd thing why you want to do but for me HTML5 + CSS + JS is unbeatable in easy to design, look and performance. Going this path will present unmatured problems I'm sure but problems exist to be solved, it fits me perfectly.

- A bonus idea is to be able to use it to run several parallal Monkey apps (Web compiled) and coordinate the communication between everything.


EDIT
I forgot SVG, one of the most mature vector formats on this Earth, perfect for printing, animation, or use in GUI's. Seem to work really well.


xlsior(Posted 2016) [#14]
That's allriight I just need a platform-independent way to play movies and mp3s,


Depending on what you're hoping to accomplish, be aware that MP3's still carry a number of patents that won't expire until late 2017 -- until then, technically you'd be required to pay licensing fees for any hardware/software that plays MP3, even if you wanted to distribute it for free.

Unless you have an actual need for MP3 specifically, it's safer/cheaper to use OGG in your program than MP3.


Casaber(Posted 2016) [#15]
True, mind you that ogg is not supported everywhere yet that's what made this started at all, well part of it. I´m writing general code that will stretch onto ios and Android.
And there's a need for minimal conversions and there's low space.

But I have already wav and ogg in mind for some things. They are very useful when the time is right.
That's why youtube is very nice to have right now, you may use to upload mp3s, and the mp3 format copyrights dissapear as its taken care of by them. Thats one of the reasons I mentioned audio/video in different configurations actually. The online traffic is no problem for me.

I noticed that you can also use the free WEBM which is movieformat that uses OGG etc as audio, and WEBP, which means to replace jpg and png.

WebP looks interesting - 25% less space than png in noncompressionmode and 25% less than jpg in compressionmode.
I love png though and jpg still looks more naturalistic. But 25%+ is huge.

Personally I feel Audio/video is well taken care of now. I was abit sceptic about Bmax when I started if it would suffice for extreme media needs.

Now I think it's a great beginning.


Casaber(Posted 2016) [#16]
WEBM is like having a free mp4, perfectly legal and possible to store everywhere locally or online, any way you want it. It fills an important void.


dw817(Posted 2016) [#17]
Casaber, I'm wondering if your perfect MIDI player routine using MCI you wrote might help you in the endeavor for video playing ?


Casaber(Posted 2016) [#18]
Ya it copes with window and fullscreen mp4 and mp3 and midi, everything could be handled. But it would not work on Mac.
I also would be abit cautious for instance when it comes to Windows RT/ARM/mobile versions, I´m not even sure what MS call all their Windows products anymore.
Also It might become a problem down the road as they throw old things away one by one.

You will get the same accelerated and smoothness with this as you would with VLC and MCI. And you can rotate and get PIP and weird things like that,
so its very useable.


Casaber(Posted 2016) [#19]
I will try this approach some more before I can say what I think of it, oh and if I get slow in response it's becuase I´m probably won't be that much online for awhile, I need to go the hospital again.

I´ve very happy with Bmax though and I feel I've learned quiet abit on these 4 weeks. It feels longer actually, lots of stuff have been going on.
Great forum great ppl. Love Bmax for so many reasons. Ya..


Casaber(Posted 2016) [#20]
Tweening works aswell in the HTML element

http://codepen.io/sdras/pen/dPqRmP


Casaber(Posted 2016) [#21]
This is the last night for quiet a while, but I will come back whenever my health is improving. I got some nice coding done tonight. But the Windows seem more picky than Mac (well, very picky it didn't work at all :s. I can get Hello world on it but not anything else. So.. ya.. Screw windows