i was made a simple video playback for android application with adobe flash using action script 3, where a flvplayback access playlist from xml file "xmlVideoPlayer.xml", and i put in folder "media/PustakaXML/xmlVideoPlayer.xml" where parent folder same with myfile.fla (project file).
can somebody help me, how to ; if i put myxml file on SDCARD on android mobile. so if i publish it, to APK, and instal on android mobile, the aplication can access myxml file on SDCARD.
below the script on my adobe flash actionscript code.
import fl.video.*;
import flash.events.Event;
import flash.net.*;
// Set Variables
var flvControl:FLVPlayback = display;
var flvIndex:Number = 0;
var loopAtEnd:Boolean = true;
// Load XML file...
var xmlList:XML;
var xmlPath:String = "media/PustakaXML/xmlVideoPlayer.xml";
//HELP HERE if file put in SDCARD
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest(xmlPath));
// Receive the XML and load the first video
function xmlLoadedHandler(event:Event):void
{
// Save XML
xmlList = new XML(xmlLoader.data);
// Set video (Start)
flvControl.source = xmlList.video[0];
}
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedHandler);
// 3. Handle video completion (load next video)
function completeHandler(event:fl.video.VideoEvent):void
{
// Get next item in list
flvIndex++;
// Validate index
if( flvIndex == xmlList.video.length() ){
if( loopAtEnd ){
flvIndex = 0;
}
else{
return;
}}
// Load next video
flvControl.source = xmlList.video[flvIndex];
}
flvControl.addEventListener(fl.video.VideoEvent.COMPLETE, completeHandler);
i am sorry my English no good enough...
Related
I have written code in ruby (similar to objective c) which plays an mp3 file from amazon s3 using AVPlayer. I want to be able to play all mp3 file stored in the directory instead of just the one who will i go about doing this??
the code i wrote is
def buttonIsTapped
p "Button was tapped"
if (#audio_player == nil)
Dispatch::Queue.concurrent.async do
mainBundle = NSBundle.mainBundle
url = NSURL.URLWithString("https://s3-eu-west-1.amazonaws.com/mytrackzmusic/music/Nines+-+Loyal+To+The+Soil/", ofType:"mp3")
##audio_player = AVAudioPlayer.alloc.initWithData(fileData, error:error)
#audio_player = AVPlayer.alloc.initWithURL(url)
#audio_player.play
#playerIsPlaying = true
end
else
if #playerIsPlaying == true
#audio_player.pause
#playerIsPlaying = false
else
#audio_player.play
#playerIsPlaying = true
end
I want to run my linked swf files on android mobile... I used adobe air for android extension in flash cs5.5 publish settings. When I published it generated filename.apk & filename.swf.
Here is the main problem is when i clicked next and previous button in one file it will not navigating to other file in android.
The individual file playing well, but I am not getting link from one file to other file using previou s and next buttons. Here is my code:
import flash.display.Loader;
import flash.events.Event;
import flash.events.MouseEvent;
// Vars
var currentMovieIndex:uint = 0;
var currentMovie:Loader;
// Put your movies here
var swfList:Array = ["apk1.swf", "apk2.swf", "apk3.swf"];
// Add the event listener to the next and previous button
previousButton.addEventListener(MouseEvent.CLICK, loadPrevious);
nextButton.addEventListener(MouseEvent.CLICK, loadNext);
// Loads a swf at secified index
function loadMovieAtIndex (index:uint) {
// Unloads the current movie if exist
if (currentMovie) {
removeChild(currentMovie);
currentMovie.unloadAndStop();
}
// Updates the index
currentMovieIndex = index;
// Creates the new loader
var loader:Loader = new Loader();
// Loads the external swf file
loader.load(new URLRequest(swfList[currentMovieIndex]));
// Save he movie reference
currentMovie = loader;
// Add on the stage
addChild(currentMovie);
}
// Handles the previous button click
function loadPrevious (event:MouseEvent) {
if (currentMovieIndex) { // Fix the limit
currentMovieIndex--; // Decrement by 1
loadMovieAtIndex(currentMovieIndex);
}
}
// Handles the next button click
function loadNext (event:MouseEvent) {
if (currentMovieIndex < swfList.length-1) { // Fix the limit
currentMovieIndex++; // Increment by 1
loadMovieAtIndex(currentMovieIndex);
}
}
// Load the movie at index 0 by default
loadMovieAtIndex(currentMovieIndex);
note:i also tested above code by replacing
var swfList:Array = ["apk1.swf", "apk2.swf", "apk3.swf"];
with
var swfList:Array = ["apk1.apk", "apk2.apk", "apk3.apk"];
I am working on an android app where I wish to download swf files from an external server, save them to sdcard and load them later in the app. Downloading works fine and the swf is saved in the application directory. Here is my code that loads the swf from the sdcard :
var myloader:Loader = new Loader();
var myhomeButton:btnHome = new btnHome();
addChild(myloader);
var swfFilePath:File = File.applicationStorageDirectory.resolvePath("Android/data/myswffile.swf");
var inFileStream:FileStream = new FileStream();
inFileStream.open(swfFilePath, FileMode.READ);
var swfBytes:ByteArray = new ByteArray();
inFileStream.readBytes(swfBytes);
inFileStream.close();
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loaderContext.allowCodeImport = true;
myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, mycompleteHandler);
myloader.loadBytes(swfBytes, loaderContext);
function mycompleteHandler(evt:Event):void
{
myloader.contentLoaderInfo.removeEventListener(Event.COMPLETE, mycompleteHandler);
addChild(myhomeButton);
myhomeButton.height = _height * 0.08;
myhomeButton.width = myhomeButton.height;
myhomeButton.x = 10;
myhomeButton.y = 10;
myhomeButton.addEventListener(MouseEvent.CLICK, myexitfftn);
}
function myexitftn(evt:Event):void
{
myloader.unloadAndStop(true);
removeChild(myhomeButton);
gotoAndStop(1, "SomeOtherFrame");
}
the problem is when I click the exit button the swf unloads but when I reload it, it starts from the second frame of the loaded swf, the third time from the third frame and so on... Where am I going wrong or what is an alternative solution, please guide.
Try, addChild(myloader) in Complete handler and removeChild and null while exiting, so that loaded swf is completely removed from the memory like so:
function mycompleteHandler(evt:Event):void
{
myloader.contentLoaderInfo.removeEventListener(Event.COMPLETE, mycompleteHandler);
addChild(myloader);
//... Rest of code remains same
}
function myexitftn(evt:Event):void
{
myloader.unloadAndStop();
removeChild(myloader);
myloader = null;
removeChild(myhomeButton);
gotoAndStop(1, "SomeOtherFrame");
}
How can i change image targets and video in videoplayback of qualcomm sdk, i have got dat and xml file for two new target images but now able to play video for those image targets, what steps should i follow two work it for two new target images and play video corresponding.
you have to give refrence of those XML in your Project just like the Reference given of the other XML for this here is sample that is also in ImageTarget Project.
In image target Project there is a method in JNI Imagetarget.cpp
Java_com_qualcomm_QCARSamples_Imagtargets_Imagetargets_loadTrackerData(JNIEnv *, jobject)
this method is dealing with multiple XML Files
it will help you how to load multiple XMLS
on the contrary if you want to detect multiple markers but with single XML and DAt file recognise your targets from the Vuforia Server combine it in single Xml file and then u can use like this
static const int NUM_TARGETS =4;
static const int Test1 = 0;
static const int Test2 = 0;
static const int Test3 = 0;
static const int Test4 = 0;
static const int Test5 = 0;
and in renderframe method
o like this
if (strcmp(trackable->getName(), "Test1 ") == 0)
currentTarget=Test1 ;
if (strcmp(trackable->getName(), "Test2 ") == 0)
currentTarget=Test2 ;
if (strcmp(trackable->getName(), "Test3 ") == 0)
currentTarget=Test3 ;
if (strcmp(trackable->getName(), "Test4 ") == 0)
currentTarget=Test4 ;
if (strcmp(trackable->getName(), "Test5 ") == 0)
currentTarget=Test5 ;
if you just want new image to be tracked and new video should play go through this:
for new target image:
replace dat and xml in asset folder in android videoplayback sample project with your dat and xml downloaded from Vuforia trackermaneger site. and don't forget to rename them to default if you don't want to build again JNI code.
for new video to be played :
either you replace video file in asset folder with same name or (i recommend this) you use any server url as video link,like this-
Uri videolink = Uri.parse("http://commonsware.com/misc/test2.3gp");
mMediaPlayer.setDataSource(mParentActivity,videolink);
in videoplaybackhelper class
hope this helps
I am converting some HTML5 to work with Android. Android does not support the element, so the play method does not function.
I am using PhoneGap's media element, and that does play audio. What I want, is a way to find the first source of the audio tag, and then use that with media play, but this does not seem to work.
function playSound(whatToPlay) {
// removed since <audio does not work
// var snd = document.getElementById(whatToPlay);
// snd.play();
toPlaySrc = $("#"+whatToPlay+":first-child").eq(0).attr("src");
// next I will have to deal with /android_asset and my current partial path
myMedia = new Media("/android_asset/"+toPlaySrc, onSuccess,onError);
if (myMedia)
myMedia.play();
}
playSound("clockticking");
this is my audio element.
<audio id="clockticking" preload="auto" autobuffer onEnded="instructionFinsihed()">
<source src="../sound/tictoc.mp3" type="audio/mp3" />
<source src="../sound/tictoc.ogg" type="audio/ogg" />
</audio>
I have many existing audio elements, so a general solution would really be important, I can not, for instance just ad id tags to all the mp3 elements and solve it.
Okay, I'm working on some monkey patch code for the Android WebView, you can see the progress over on my corinthian github project. In the meantime what you'd want to do is setup a on deviceready listener:
document.addEventListener("deviceready", monkeypunch, true);
create an array to hold the media objects:
mediaObjs = [];
and in the monkeypunch method you would do:
function monkeypunch() {
var audioclips = document.getElementsByTagName("audio");
for (var i=0; i < audioclips.length; i++) {
// Create new Media object.
var audioSrc = audioclips[i].firstElementChild.src;
if (audioSrc.indexOf("file:///android_asset") == 0) {
audioSrc = audioSrc.substring(7);
}
mediaObjs[audioSrc] = new Media(audioSrc);
// Create the HTML
var newAudio = document.createElement('div');
var newImg = document.createElement('img');
newImg.setAttribute('src', 'images/play.png');
newAudio.appendChild(newImg);
// Set the onclick listener
newAudio.addEventListener("click", function() {
// figure out what image is displayed
if (newImg.src.indexOf("images/play.png", newImg.src.length - "images/play.png".length) !== -1) {
newImg.src = "images/pause.png";
mediaObjs[audioSrc].play();
} else {
newImg.src = "images/play.png";
mediaObjs[audioSrc].pause();
}
});
// replace the audio tag with out div
audioclips[i].parentNode.replaceChild(newAudio, audioclips[i]);
}
}
You can grab the play/pause images from my github project. I'm planning on adding more functionality when I have some more time.