flash music player not playing after second time - flash-cs5

i am new to flash. i was created flash player for my online radio. it's working fine first two time when i use the stop and play button. the third time it will not playing. i don't know why is not playing , i am using action script 3.0 , my action script is here
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import fl.events.SliderEvent;
// objects
var soundfile:URLRequest = new URLRequest('http://www.xxx.com:80/;stream1.mp3');
var channel:SoundChannel = new SoundChannel();
var sTransform:SoundTransform = new SoundTransform();
// controls
btnplay.addEventListener(MouseEvent.CLICK,playmusic);
btnstop.addEventListener(MouseEvent.CLICK,stopmusic);
sldVolume.addEventListener(SliderEvent.CHANGE,changevolume);
function playmusic(evt:MouseEvent):void
{
var myMusic:Sound = new Sound();
myMusic.load(soundfile);
myMusic.play();
}
function changevolume(evt:SliderEvent):void
{
sTransform.volume = sldVolume.value;
channel.soundTransform = sTransform;
}
function stopmusic(evt:MouseEvent):void
{
sldVolume.removeEventListener(Event.COMPLETE, changevolume);
SoundMixer.stopAll();
}

Related

how to parse a value to a 2Dtext in spark ar

I have an X value representing how much I open my mouth in spark AR. How can I show that X value into a 2d text?
I expect the text to show the Number value while running the effect.
You should use this script:
const Scene = require('Scene');
// Use export keyword to make a symbol available in scripting debug console
export const Diagnostics = require('Diagnostics');
// To use variables and functions across files, use export/import keyword
// export const animationDuration = 10;
// Use import keyword to import a symbol from another file
// import { animationDuration } from './script.js'
// To access scene objects
// const directionalLight = Scene.root.find('directionalLight0');
// To access class properties
// const directionalLightIntensity = directionalLight.intensity;
// To log messages to the console
Diagnostics.log('Console message logged from the script.');
const Patches = require('Patches');
const numberFormat = '{0}';
const number = Patches.getScalarValue('number');
Patches.setStringValue('value', number.format(numberFormat));
enter image description here

NodeJS inherits

I've created some scripts and instantiated them on my main script
var eagle1 =new Fleet.F15c(456);
var eagle2 = new Fleet.F15c(123);
var falcon1 = new Fleet.F16(111);
var guardian1 = new Fleet.F14(789);
and have some functions
And now I wanna create a wing - so when the wing is ordered to do something, all the planes assigned to that wing will execute.
I created a 'wing command' script that should have 2 functions that will be called from the main script:
AssignCommand (orderName, planefunction) ->logs the plane function listener to the event emitter of that wing
ExecuteCommand (orderName) -> emits orderName
var EventEmitter = require('events');
var util = require('util');
util.inherits(WingCommand,EventEmitter);
module.exports = WingCommand;
function WingCommand(){
}
But when I created the 1st func
WingCommand.prototype.AssignCommand = function (CommandName , PlaneFunc(data=null)){
this.on(CommandName,PlaneFunc(data));
}
I did not manage figure out the unexpected token on this line
WingCommand.prototype.AssignCommand = function (CommandName , PlaneFunc(data=null)){
I tried some tutorials but did not find a solution
will appreciate your help

Background music xcode 7 swift

I´ve already made an app but now I want to play background audio in my app when it launch with endless loop. I know it´s a dumb question but I would be happy if anybody can help me. Thanks in advance. :)
This is a broad question, but here is one example of what you can do.
Make sure you, above your class declaration, import the AVFoundation framework, like so:
import AVFoundation
If you have a .mp3 file and you want to play it and loop it endlessly, you can use the following code to do so:
var audioPlayer = AVAudioPlayer()
func startAudio() {
let filePath = NSBundle.mainBundle().pathForResource("fileName", ofType: "mp3")
let fileURL = NSURL.fileURLWithPath(filePath!)
do {
audioPlayer = try AVAudioPlayer.init(contentsOfURL: fileURL, fileTypeHint: AVFileTypeMPEGLayer3)
audioPlayer.numberOfLoops = -1
audioPlayer.volume = 1
} catch {
self.presentViewController(UIAlertController.init(title: "Error", message: "Error Message", preferredStyle: .Alert), animated: true, completion: nil)
}
audioPlayer.play()
}
Call this function wherever you want in your controller and the audio should start playing. Hope this helps.

Cycling images in a live tile

I have a winJS app that is a working launcher for a steam game. I'd like to get it to cycle through 5 images even while not running.
It uses only the small tile — there are no wide tiles images for this app.
Here's the code:
(function () {
"use strict";
WinJS.Namespace.define("Steam", {
launch: function launch(url) {
var uri = new Windows.Foundation.Uri(url);
Windows.System.Launcher.launchUriAsync(uri).then(
function (success) {
if (success) {
// File launched
window.close();
} else {
// File launch failed
}
}
);
}
});
WinJS.Namespace.define("Tile", {
enqueue: function initialize() {
var updaterHandle = Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication();
updaterHandle.enableNotificationQueue(true);
return updaterHandle;
},
update: function update () {
var template = Windows.UI.Notifications.TileTemplateType.tileSquareImage;
var tileXml = Windows.UI.Notifications.TileUpdateManager.getTemplateContent(template);
var randIndx = Math.floor(Math.random() * 5);
var randUpdatetime = 1000 * 3 * (((randIndx == 0) ? 1 : 0) + 1); // let the base image stay longer
var tileImageAttributes = tileXml.getElementsByTagName("image");
tileImageAttributes[0].setAttribute("src", "ms-appx:///images/Borderlands2/borderlands_2_" + randIndx + "_sidyseven.png");
tileImageAttributes[0].setAttribute("alt", "Borderlands 2");
var tileNotification = new Windows.UI.Notifications.TileNotification(tileXml);
var currentTime = new Date();
tileNotification.expirationTime = new Date(currentTime.getTime() + randUpdatetime);
tileNotification.tag = "newTile";
var updater = Tile.enqueue();
updater.update(tileNotification);
setTimeout('Tile.update();', randUpdatetime);
}
});
WinJS.Binding.optimizeBindingReferences = true;
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
setTimeout('Steam.launch("steam://rungameid/49520");', 800);
args.setPromise(WinJS.UI.processAll().then(function () {
return WinJS.Navigation.navigate("/default.html", args).then(function () {
Tile.update();
});
}));
}
};
app.start();
})();
Notes:
The code currently does not cycle the image, instead either
apparently never changing, or after launch replacing the application
name text with a tiny view of the default image. This reverts to the
text after a short time, and the cycle may repeat. It never shows a
different image (neither in the small image it erroneously shows, nor
in the main tile).
When I run in debug and set a breakpoint at the
TileUpdater.update(TileNotification) stage, I can verify in the
console that the image src attribute is set to a random image
just as I wanted:
>>>>tileNotification.content.getElementsByTagName("image")[0].getAttribute("src")
"ms-appx:///images/Borderlands2/borderlands_2_4_sidyseven.png"
But this never actually displays on the tile.
These image files are included in the solution, and they appear in the proper directory in the Solution Explorer.
If the image src attribute is set properly in debug then the image may not have the proper "Build Action".
In the 'Properties' of each image, set "Build Action" to "Resource".

Unable to create Spotify app playlist view

I'm trying to display a simple playlist view in my Spotify app with the following code:
sp = getSpotifyApi(1);
var m = sp.require("sp://import/scripts/api/models");
var v = sp.require("sp://import/scripts/api/views");
var jq = sp.require('sp://XXX/jquery/jquery-1.7.1.min');
var pl = m.Playlist.fromURI('spotify:user:d3marcus:playlist:4zPZzImEYkUOVBvxIo42im');
var player = new v.Player();
player.track = pl.get(0);
player.context = pl;
var list = new v.List(pl);
$('XXX').append(list.node);
This will result in an empty list view and an error caught in sp://import/scripts/language.js:44: "Uncaught TypeError: Cannot read property 'length' of undefined"
Any suggestions?
I would say you are getting this error because the playlist has not yet loaded when you do pl.get(0). To make sure the playlist model has loaded you could either do
pl = m.Playlist.fromURI('spotify:user:d3marcus:playlist:4zPZzImEYkUOVBvxIo42im');
pl.observe(models.EVENT.LOAD, function() {
player.track = pl.get(0);
...
});
or
m.Playlist.fromURI("spotify:user:d3marcus:playlist:4zPZzImEYkUOVBvxIo42im", function(pl) {
player.track = pl.get(0);
...
});
I'm not sure, but could you try this :
$('YYY').append($(player.node));
$('XXX').append($(list.node));
instead of
$('XXX').append(list.node);
let us know...
For the 1.0 API:
require([
'$api/models',
'$views/list#List'
], function (models,List) {
var addList = function(list) {
list.load('tracks').done(function(list) {
list.tracks.snapshot().done(function(trackSnapshot){
// Make the playlist view
var multiple_tracks_player = document.getElementById('addedTracksList');
var playableList = List.forPlaylist(list);
multiple_tracks_player.appendChild(playableList.node);
playableList.init();
});
});
}
exports.addList = addList;
}
// Example of use:
addList(models.Playlist.fromURI(...))
I've tested it as used above, so it should work.
I found this in the tutorial-app available on github under "Playing music"-section -> "Play a list of tracks"
I hope this is helpfull.

Resources