Prevent FLV Buffering (AS FLVPlayback component) - flash-cs4

I have a client who is insisting on having a 65Mb FLV on her home page. I talked her down off of the auto-play ledge but I am concerned about wasting bandwidth on a movie that one in 30 visitors might play.
In looking at the docs for the FLVPlayback component here the only buffer related parameter I found was
bufferTime
Number of seconds to buffer before beginning playback. The default value is 0.
The only solution I have come up with is to load a jpeg still of the player and replace it onclick with the SWF.
Anyone have a cleaner solution to prevent wasted bandwidth?
Thanks.

I (literally) just sorted out the same issue (was looking for easy answers when I found your question)
My solution was to use a bit of Actionscript to not give the name of the flv file to the FlvPlayback until the first time the play button was clicked. Snippet of Actionscript 3 code below ( myVideo is the instance name I used for the FlvPlayback component and BigButton is the name of the Play button I display).
var firstplay=true;
var moviefile = "nameofmovie";
function playMovie(event:MouseEvent):void {
if (firstplay) {
myVideo.source = moviefile +".flv";
firstplay = false;
}
myVideo.play();
}
BigButton.addEventListener(MouseEvent.CLICK, playMovie);

Related

Cannot set URL after the fact on Ti.Media.createSound()

I can successfully play a remote mp3 via the Titanium.Media.Sound object, but there is a problem. The 1st clip always plays fine. But each time I try to play a different clip, the first clip plays again. This is 100% repeatable.
So at the top of my js file I'm doing this:
var soundPlayer = Ti.Media.createSound({allowBackground: false});
Then inside the event listener for a button click, I'm setting the URL thusly:
soundPlayer.setUrl(mp3URL);
And I have even tried this approach:
soundPlayer.url = mp3URL;
But they both have the same flaw: the audio is always still the first clip, never any clip I set afterward. I have verified via console logging that in fact a new url was handed to the sound player, and in fact the new url points at a valid mp3. It seems that once I set a url for the sound player, it is set in stone and cannot be changed--just replayed.
So then I tried a completely different approach. Inside my button click listener, I re-create the Sound object each time and hand in the new URL:
soundPlayer = Ti.Media.createSound({allowBackground: false, url: mp3URL});
This actually DOES work and plays the new url each time, BUT it has a terrible side effect: any attached event listeners no longer fire. I need to track state changes in the player, for example when it completes, etc. But these event listeners no longer fire when I take this approach.
Strangely, the AudioPlayer object behaves correctly in all respects, allows me to set new URLs, etc. BUT the problem with that is that AudioPlayer absolutely refuses to play any mp3 file smaller than 40Kb. I have posted questions around that issue on this and other forums, and based on responses and experimentation, I have lots of evidence for the 40Kb limitation, and no evidence to the contrary.
So why can't I change the url after object creation on the Sound object? Thanks in advance for any ideas.
I'd put this in the "Known bug" category, see here: https://jira.appcelerator.org/browse/TIMOB-3348 marked as "won't fix".
Bug report:
var sound = Titanium.Media.createSound();
sound.url='../cricket.wav'; sound.play();
But if I try to change the url after that, sound plays still the cricket.wav
sound.
Response from Appcelerator(?):
"Duplicate of customer issue TIMOB-1488. This can be easily achieved
by creating a new sound object. Furthermore, this would create a
platform parity issue and would complicate any future API that, for
example, would support sound channels, etc. A sound object should be
considered an immutable object once it's constructed."
So create a new sound object and re-add the event listeners is the solution I think:
var sampleListener = function(){
alert('something happened');
}
var sound = Ti.Media.createSound({url:myURL});
sound.addEventListener('complete', sampleListener);
sound.play();
//later on, make a new sound object:
sound = Ti.Media.createSound({url:anotherURL});
sound.addEventListener('complete', sampleListener);
sound.addEventListener('someevent', anotherSampleListener);
sound.play();
Just so know, this is happening to the Ti.Media.AudioPlayer also. The proposed solution will work just fine in that case as well.

SoundCloud Widget API setVolume Method broken?

I'm successfully using Soundcloud's widget API, except the setVolume() method is broken :(
First, I love the widget, but I'm blown away that after all that amazing work there is no volume control available! People will immediately "back button" out of my site when they hear 100% audio and I can't alter it using setVolume()... I have to get it working or pull it :(
Here is what is happening, I have an instance named "widget" (which loads and plays well on the page).
widget.bind(SC.Widget.Events.READY, function() {
$('#audioIndictments').removeClass('remove'); // This disables a CSS rule, making the soundCloud iframe visible
widget.setVolume(10); // This should set the volume to 10% but doesn't :(
widget.getVolume(function(vol){
console.log(vol); // This outputs 0.1 in the console :/
console.log(widget); // This outputs the object in the console and I don't see anything out of whack :|
});
widget.play(); // This successfully fires up the widget and the audio begins playing :)
widget.setVolume(10); // Just to see if it makes a difference, after the play() method, I ran setVolume again after the play() method and still no change :(
widget.getVolume(function(vol){
console.log(vol); // This still outputs 0.1 in the console :/
});
});
Strange results. I found another blogger who asked a similar question and got no satisfactory answer. What's the deal here? What am I not seeing?
Thank you for taking the time :)
Try using the a volume between 0 and 1. This fixed it for me.
0.25 = 25% volume
I too am facing the same issue and I discovered that the volume does not reset to full when setVolume method is called outside of the READY event. This is why the setVolume button on the SC api playground works since it's called externally. But there is another problem - when the next track in the playlist is loaded into the widget, it resets the volume back to full and as a result, deafens the user.
I've used a hacky workaround until this is fixed.
Setup a new PLAY_PROGRESS event and call the method inside there.
widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
widget.setVolume(10);
});
The setVolume method will continuously be called when the track is played. Not ideal but it works.
If you have a slider in place for volume then you may use this instead:
widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
var vol = jQuery('.slider').val();
widget.setVolume(vol);
});

Video.js controls come back on pause even though disabled

The subject pretty much says it all. I have a Video.js instance with controls turned off (aka no "controls" in the markup). It works brilliantly, but when I pause the video (using my external custom button and myPlayer.pause() the controls on the video fade back in. When I hit play, they fade out again.
This definitely doesn't seem like the way it should work. Does anyone know if this is a bug, or I'm just missing something?
ctangney's answer only works when using the uncompressed (dev) version of videojs, since once compressed the lockShowing method is renamed (so is player() for that matter). Hopefully his merge request for issue 556 will be accepted soon.
When lockShowing is called on pause() it adds the class vjs-lock-showing to the controls element, which has the css: display: block !important. This is causing the inline style of display:none, added by the disable() method, to be trumped. Here is work around which addresses the CSS specificity problem, and works with the compressed and uncompressed videojs:
var v = videojs("video", {});
if(!v.controls()) {
v.controlBar.el().className = v.controlBar.el().className + ' vjs-controls-disabled';
}
Then add to the bottom of the css file(s):
.vjs-controls-disabled {display: none !important;}
(Or you could just remove the !important from .vjs-lock-showing)
This is a confirmed bug. I see a proposed fix there, but it's still an open pull request at the moment. In the meantime you can fix this by just overwriting the ControlBar's lockShowing method.
var vid = videojs("video", {});
if (!vid.player().controls()) {
vid.controlBar.lockShowing = function(){};
}
... since (currently) the controlbar attaches a listener to 'pause' events and calls lockShowing().

Ti.Geolocation callbacks only works when running KitchenSink

I have a problem with Ti.Geolocation that drives me crazy. Only using IOS platform so far. The goal is to get GPS callbacks with highest possible accuracy when I move around with the phone.
The problem is that I have copied most of the code from geolocation.js in KitchenSink, with the relevant part shown below. It looks OK to me, however the behaviour I get is very strange.
I just don't get regular GPS callbacks when I walk around! The compass works fine however and sends me callbacks all the time. I have also tried without subscribing to 'heading' events, but no change in GPS behaviour.
There is only one event that can trigger a GPS-callback with correct data, and that is running KitchenSink! Switching to KitchenSink and back also gives me a callback with accuracy between 5 and 10. If I don't do that, my accuracy can be as high as 1500-2500 (if I get a callback at all, that is).
KitchenSink seems to work fine, but I fail to see what that app does that I do not?!?
I have turned off Wifi in the phone so it wont disturb. This problem is very frustrating and I have spent three days on it now, can someone please help? I have tried compiling against different SDK's too (normally 2.1.1GA but also down to 1.8.2). No change.
if (locationServicesAvailable()) {
// APPLICATION LOGIC
ui.init();
Ti.Geolocation.purpose = "Get Lat/Long of your current position";
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
Ti.Geolocation.distanceFilter = 10;
Ti.Geolocation.frequency = 0; /* as fast as possible */
Ti.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS;
if (Ti.Geolocation.hasCompass) {
// TURN OFF ANNOYING COMPASS INTERFERENCE MESSAGE
Ti.Geolocation.showCalibration = false;
// SET THE HEADING FILTER (THIS IS IN DEGREES OF ANGLE CHANGE)
// EVENT WON'T FIRE UNLESS ANGLE CHANGE EXCEEDS THIS VALUE
Ti.Geolocation.headingFilter = 45;
/*
Ti.Geolocation.getCurrentHeading(handleCompass);
Ti.Geolocation.addEventListener('heading', handleCompass);
*/
}
Ti.Geolocation.getCurrentPosition(handlePosition);
Ti.Geolocation.addEventListener('location', handlePosition);
ui.refresh.addEventListener('click', function(e) {
Ti.Geolocation.getCurrentPosition(handlePosition);
});
}
OK it seems I have found an answer to my problem. It's as simple as setting accuracy to Ti.Geolocation.ACCURACY_NEAREST_TEN_METERS. I'm using the IOS platform, and I'm located in Sweden (in the countryside) if it matters. Don't know if this solution applies to everyone, but I have seen references to this problem (http://developer.appcelerator.com/question/130596/strange-behavior-of-the-gps) and solution so I know it exists.
No idea why ACCURACY_BEST doesnt work, but it doesnt for me. I'll test all the other settings too when I get the time but now at least I can continue developing.

Kaltura - Force player to stop with API only?

Is there any way to force a Kaltura videoplayer to stop ONLY using code and the Kaltura API?
Currently I have solved it by adding a Access Control Profile named "Free preview" under Settings > Access Control in KMC and then added this profile to the Entries I've choosen.
I then add the session to the players flashvars to restrict non-members to only watch the preview, not the whole clip.
But I would like to restrict ALL, or even better selected Categories of clips by using only code, so I don't need to involve KMC.
Is that possible?
Alt) Can you create a new player in KMC and restrict it to viewing only X seconds, no matter what length of Entry? Then I can do the check if user is valid or not and get the category via API and show it in the "preview-player" och the "default player".
If I use the mediaProxy.mediaPlayTo attribute the clip stops, but is easily started again by presing play.
Would greatly appreciate an answer
I got this answer from a guy named oferc in a different forum:
You can listen to the head move event and pause the clip it goes beyond a certain time (then if someone pressed play, you can stop it again)
function jsCallbackReady(player_id) {
my_kdp = $("#"+player_id).get(0); // document.getElementById(player_id) if you do not use jquery/ prefer pure js
my_kdp.addJsListener("kdpReady", "kdpReady"); // when you load the player with an entry (and the player is ready to begin playing it using doPlay for instance)
}
function kdpReady() {
my_kdp.addJsListener("playerUpdatePlayhead","headMove");
}
function headMove(position) {
if (position > "30") { // Your Time, example 30 seconds
my_kdp.sendNotification('doStop')
}
}
Works like a charm!
fredrik_w - neither of the ways you chosen here are a good option to restrict access.
in both cases, your videos are made public, and can be easily accessible by anyone.
The best way to limit access to a video is by defining an Access Control, and like everything in Kaltura, you can define an ACL using API as well.
Check this out as a reference sample-
http://blog.kaltura.org/turning-profit-online-video-made-easy-using-paypal-html5-digital-goods