Search Results

Search found 601 results on 25 pages for 'song yuan'.

Page 5/25 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Django: Serving a Download in a Generic View

    - by TheLizardKing
    So I want to serve a couple of mp3s from a folder in /home/username/music. I didn't think this would be such a big deal but I am a bit confused on how to do it using generic views and my own url. urls.py url(r'^song/(?P<song_id>\d+)/download/$', song_download, name='song_download'), The example I am following is found in the generic view section of the Django documentations: http://docs.djangoproject.com/en/dev/topics/generic-views/ (It's all the way at the bottom) I am not 100% sure on how to tailor this to my needs. Here is my views.py def song_download(request, song_id): song = Song.objects.get(id=song_id) response = object_detail( request, object_id = song_id, mimetype = "audio/mpeg", ) response['Content-Disposition'= "attachment; filename=%s - %s.mp3" % (song.artist, song.title) return response I am actually at a loss of how to convey that I want it to spit out my mp3 instead of what it does now which is to output a .mp3 with all of the current pages html contained. Should my template be my mp3? Do I need to setup apache to serve the files or is Django able to retrieve the mp3 from the filesystem(proper permissions of course) and serve that? If it do need to configure Apache how do I tell Django that? Thanks in advanced. These files are all on the HD so I don't need to "generate" anything on the spot and I'd like to prevent revealing the location of these files if at all possible. A simple /song/1234/download would be fantastic.

    Read the article

  • Prevent empty form input array from being posted?

    - by user355295
    Sorry if this has been answered somewhere; I'm not quite sure how to phrase the problem to even look for help. Anyway, I have a form with three text input boxes, where the user will input three song titles. I have simple PHP set up to treat those input boxes as an array (because I may want, say, 100 song titles in the future) and write the song titles to another document. <form method="post"> <input type="text" name="songs[]" value="" /> <input type="text" name="songs[]" value="" /> <input type="text" name="songs[]" value="" /> <button type="submit" name="submit" value="submit">Submit</button> </form> <?php if (isset($_POST['submit'])) { $open = fopen("test.html", "w"); if(empty($_POST['songs'])) { } else { $songs = $_POST['songs']; foreach($songs as $song) { fwrite($open, $song."<br />"); }; }; }; ?> This correctly writes the song titles to an external file. However, even when the input boxes are empty, the external file will still be written to (just with the <br />'s). I'd assumed that the if statement would ensure nothing would happen if the boxes were blank, but that's obviously not the case. I guess the array's not really empty like I thought it was, but I'm not really sure what implications that comes with. Any idea what I'm doing wrong? (And again, I am clueless when it comes to PHP, so forgive me if this has been answered a million times before, if I described it horribly, etc.)

    Read the article

  • XNA extending an existing Content type

    - by Maarten
    We are doing a game in XNA that reacts to music. We need to do some offline processing of the music data and therefore we need a custom type containing the Song and some additional data: // Project AudioGameLibrary namespace AudioGameLibrary { public class GameTrack { public Song Song; public string Extra; } } We've added a Content Pipeline extension: // Project GameTrackProcessor namespace GameTrackProcessor { [ContentSerializerRuntimeType("AudioGameLibrary.GameTrack, AudioGameLibrary")] public class GameTrackContent { public SongContent SongContent; public string Extra; } [ContentProcessor(DisplayName = "GameTrack Processor")] public class GameTrackProcessor : ContentProcessor<AudioContent, GameTrackContent> { public GameTrackProcessor(){} public override GameTrackContent Process(AudioContent input, ContentProcessorContext context) { return new GameTrackContent() { SongContent = new SongProcessor().Process(input, context), Extra = "Some extra data" // Here we can do our processing on 'input' }; } } } Both the Library and the Pipeline extension are added to the Game Solution and references are also added. When trying to use this extension to load "gametrack.mp3" we run into problems however: // Project AudioGame protected override void LoadContent() { AudioGameLibrary.GameTrack gameTrack = Content.Load<AudioGameLibrary.GameTrack>("gametrack"); MediaPlayer.Play(gameTrack.Song); } The error message: Error loading "gametrack". File contains Microsoft.Xna.Framework.Media.Song but trying to load as AudioGameLibrary.GameTrack. AudioGame contains references to both AudioGameLibrary and GameTrackProcessor. Are we maybe missing other references? EDIT Selecting the correct content processor helped, it loads the audio file correctly. However, when I try to process some data, e.g: public override GameTrackContent Process(AudioContent input, ContentProcessorContext context) { int count = input.Data.Count; // With this commented out it works fine return new GameTrackContent() { SongContent = new SongProcessor().Process(input, context) }; } It crashes with the following error: Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Users\Maarten\Documents\Visual Studio 2010\Projects\AudioGame\DebugPipeline\bin\Debug\DebugPipeline.exe'. Additional Information: A call to PInvoke function 'Microsoft.Xna.Framework.Content.Pipeline!Microsoft.Xna.Framework.Content.Pipeline.UnsafeNativeMethods+AudioHelper::OpenAudioFile' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. Information from logger right before crash: Using "BuildContent" task from assembly "Microsoft.Xna.Framework.Content.Pipel ine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553". Task "BuildContent" Building gametrack.mp3 -> bin\x86\Debug\Content\gametrack.xnb Rebuilding because asset is new Importing gametrack.mp3 with Microsoft.Xna.Framework.Content.Pipeline.Mp3Imp orter Im experiencing exactly this: http://forums.create.msdn.com/forums/t/75996.aspx

    Read the article

  • Music Manager that can properly see ID3 ratings tags and synchronize with Android

    - by Sebastian
    I'm moving from Windows 7 to Ubuntu, and so far the experience has been a really good one :) However, there is something that I've used to do with Windows 7 that I can't find how to do in Ubuntu: From my Windows music manager programs (either MediaMonkey or Windows Media Player) I could set song ratings in a way that the ratings set from either program could be also read from the other one. Additionally, song ratings were visible and updated in my iPod Touch when I synch'ed my music (either manually or using iTunes). To sum up, it seems that MediaMonkey, WMP, and the iPod device use standard mp3 metadata tag for ratings. Now, using Ubuntu 12.04, and now with an Android device: Rhythmbox can't see the song rates, despite those ratings can be seen by MediaMonkey and MS Music Player when I boot with Win7. Is this an issue I can fix with some setting? Is there any program I can use to accomplish this? What do you recommend to sync my music with Android (4.0, Galaxy s2), also keeping the song ratings information updated between Android and my PC? Thanks!!

    Read the article

  • windows 8 + Ubuntu dual boot

    - by Jack Yuan
    I installed Ubuntu 13.04 on Windows 8. Yes I can access both of them, but the process is kind of long. In BIOS, EFI is for Windows 8, legacy support is for Ubuntu. If I choose EFI first, the startup just go straight to Win8 without offering me a choice. If I choose legacy first, the starup will offer me a choice between win8 and ubuntu. But I can only choose Ubuntu. If i choose win8, there will be a mistake(file missing under configuration). That is to say, every time i wanna switch to another OS, I have to go into BIOS and change the priority settings. I heard something about secure boot might be the cause of this situation. But the thing is that there is not even an option called "secure boot" in my BIOS, which means i cannot disable it. All I want is that an option menu appears everytime i turn on my computer so i can easily choose what OS I want for today. Can anyone help me plz? Thank you very much!!

    Read the article

  • Can I keep stream info displayed while in a full screen visualization in VLC?

    - by Daniel
    I am streaming an internet radio station through vlc. When its playing in the player, the title bar shows the song title and artist. When going full screen, it shows the song title/artist for a brief moment in white at the bottom of the screen. But, that quickly disappears. It does not come back up when the song changes. Is there a way to keep the stream info on screen while in full screen visualization mode in vlc?

    Read the article

  • How do I create an instance of this class in Android?

    - by Lloyd Banks
    I was wondering if it is possible to create an instance of this class (from the link, which creates a listview) from another class so that I can call on either lazyadapter.java or customizedlistview.java (not sure which one) to inflate that same listview. Is this possible? This is what I tried (obviously incorrect): CustomizedListView clv = new CustomizedListView(); clv.onCreate(...); source: http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/ LazyAdapter.java import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; public class LazyAdapter extends BaseAdapter { private Activity activity; private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data; private static LayoutInflater inflater=null; public ImageLoader imageLoader; public LazyAdapter(Activity a, ArrayList&lt;HashMap&lt;String, String&gt;&gt; d) { activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader=new ImageLoader(activity.getApplicationContext()); } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { View vi=convertView; if(convertView==null) vi = inflater.inflate(R.layout.list_row, null); TextView title = (TextView)vi.findViewById(R.id.title); // title TextView artist = (TextView)vi.findViewById(R.id.artist); // artist name TextView duration = (TextView)vi.findViewById(R.id.duration); // duration ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image HashMap&lt;String, String&gt; song = new HashMap&lt;String, String&gt;(); song = data.get(position); // Setting all values in listview title.setText(song.get(CustomizedListView.KEY_TITLE)); artist.setText(song.get(CustomizedListView.KEY_ARTIST)); duration.setText(song.get(CustomizedListView.KEY_DURATION)); imageLoader.DisplayImage(song.get(CustomizedListView.KEY_THUMB_URL), thumb_image); return vi; } } CustomizedListView.java import java.util.ArrayList; import java.util.HashMap; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; public class CustomizedListView extends Activity { // All static variables static final String URL = "http://api.androidhive.info/music/music.xml"; // XML node keys static final String KEY_SONG = "song"; // parent node static final String KEY_ID = "id"; static final String KEY_TITLE = "title"; static final String KEY_ARTIST = "artist"; static final String KEY_DURATION = "duration"; static final String KEY_THUMB_URL = "thumb_url"; ListView list; LazyAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); XMLParser parser = new XMLParser(); String xml = parser.getXmlFromUrl(URL); // getting XML from URL Document doc = parser.getDomElement(xml); // getting DOM element NodeList nl = doc.getElementsByTagName(KEY_SONG); // looping through all song nodes &lt;song&gt; for (int i = 0; i &lt; nl.getLength(); i++) { // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); Element e = (Element) nl.item(i); // adding each child node to HashMap key =&gt; value map.put(KEY_ID, parser.getValue(e, KEY_ID)); map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE)); map.put(KEY_ARTIST, parser.getValue(e, KEY_ARTIST)); map.put(KEY_DURATION, parser.getValue(e, KEY_DURATION)); map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL)); // adding HashList to ArrayList songsList.add(map); } list=(ListView)findViewById(R.id.list); // Getting adapter by passing xml data ArrayList adapter=new LazyAdapter(this, songsList); list.setAdapter(adapter); // Click event for single list row list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { } }); } }

    Read the article

  • How do I make my purchased music be synchronized on Rhythmbox and in ~./ubuntuone/Purchased from Ubuntu One?

    - by dln9
    I am signed up for the Ubuntu One service, and have my computer added. Under System ? Preferences ? Ubuntu One, I have enabled all synchronizations, including for music. System ? Prefereneces ? Ubuntu One, it shows this message: "Synchronization Complete". But, when (via Rhythmbox) I purchase a song, no synchronization occurs. I can see the purchased song on the Ubuntu One web page, but the "Purchased Music" folder in Rhythmbox is empty, and the folder ~/.ubuntuone/Purchased from Ubuntu One is also empty. (So, the only way I can get at the song is to manually download it from the Ubuntu One web site to my computer.) I thought that these synchronizations should just happen automatically, but it appears that is not the case for me, and I can't figure out why. Thanks in advance for any help.

    Read the article

  • Ubuntu One Music - 'Unable to Parse '2006-12-12T08:00:00Z' as integer (iTunes Non-DRM AAC)

    - by Scott
    Good Morning; Title says most of it, uploaded a new song to my U1 Music (via my Android using the Files app). Which is an recently purchased iTunes .m4a song, so is non-DRM AAC. Uploaded fine, and browsing in U1 Music I see artist "Spray" fine, and then the Album, but attempting to open the Album to the song, returns: "'Unable to Parse '2006-12-12T08:00:00Z' as integer" Not sure if it's a problem with the file itself, or just how Android uploaded the file, as that is clearly a weird date code. All my other music is fine, no errors, and the service works awesome. My U1 account is under the e-mail address used for this question. Thanks!

    Read the article

  • How to detect flash based music player is done with playing music

    - by rsapru
    Hi, I am trying to create a very basic\ minimalistic playlist application for http://www.google.co.in/music. Basically Google music displays links to song and when clicked it opens flash based player. Using my application i am collecting music links into a list box, when an song is clicked it opens the link in a separate webbrowser and it starts playing. As of now to achieve playlist functionality i also collect the time for each song and based on that i create a timer, once the time is over it switches to other song. My Question here is that, is it possible to detect when the flash player is done playing music. Currently the timer functionality that i have built is not reliable. If interested you can have a look at code http://gmp.codeplex.com/

    Read the article

  • Problems extracting information from RSS feed description field

    - by Graeme
    Hi, I've built an iPhone application using the parsing code from the TopSongs sample iPhone application. I've hit a problem though - the feed I'm trying to parse data from doesn't have a separate field for every piece of information (i.e. if it was for a feed about dogs, all the information such as dog type, dog age and dog price is contained in the feed. However, the TopSongs app relies on information having its own tags, so instead of using it uses and . So my question is this. How do I extract this information from the description field so that it can be parsed using the TopSongs parser? Can you somehow extract the dog age, price and type information using Yahoo Pipes and use that RSS feed for the feed? Or is there code that I can add to do it in application? Update: To view the code of my application parser (based on the TopSongs Core Data Apple provided application, see below. Here's a sample of one item from the the actual RSS feed I'm using (the description is longer, and has status,size, and a couple of other fields, but they're all formatted the same.: <item> <title>MOE, MARGRET STREET</title> <description> <b>District/Region:</b>&nbsp;REGION 09</br><b>Location:</b>&nbsp;MOE</br><b>Name:</b>&nbsp;MARGRET STREET</br></description> <pubDate>Thu,11 Mar 2010 05:43:03 GMT</pubDate> <guid>1266148</guid> </item> /* File: iTunesRSSImporter.m Abstract: Downloads, parses, and imports the iTunes top songs RSS feed into Core Data. Version: 1.1 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2009 Apple Inc. All Rights Reserved. */ #import "iTunesRSSImporter.h" #import "Song.h" #import "Category.h" #import "CategoryCache.h" #import <libxml/tree.h> // Function prototypes for SAX callbacks. This sample implements a minimal subset of SAX callbacks. // Depending on your application's needs, you might want to implement more callbacks. static void startElementSAX(void *context, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes); static void endElementSAX(void *context, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI); static void charactersFoundSAX(void *context, const xmlChar *characters, int length); static void errorEncounteredSAX(void *context, const char *errorMessage, ...); // Forward reference. The structure is defined in full at the end of the file. static xmlSAXHandler simpleSAXHandlerStruct; // Class extension for private properties and methods. @interface iTunesRSSImporter () @property BOOL storingCharacters; @property (nonatomic, retain) NSMutableData *characterBuffer; @property BOOL done; @property BOOL parsingASong; @property NSUInteger countForCurrentBatch; @property (nonatomic, retain) Song *currentSong; @property (nonatomic, retain) NSURLConnection *rssConnection; @property (nonatomic, retain) NSDateFormatter *dateFormatter; // The autorelease pool property is assign because autorelease pools cannot be retained. @property (nonatomic, assign) NSAutoreleasePool *importPool; @end static double lookuptime = 0; @implementation iTunesRSSImporter @synthesize iTunesURL, delegate, persistentStoreCoordinator; @synthesize rssConnection, done, parsingASong, storingCharacters, currentSong, countForCurrentBatch, characterBuffer, dateFormatter, importPool; - (void)dealloc { [iTunesURL release]; [characterBuffer release]; [currentSong release]; [rssConnection release]; [dateFormatter release]; [persistentStoreCoordinator release]; [insertionContext release]; [songEntityDescription release]; [theCache release]; [super dealloc]; } - (void)main { self.importPool = [[NSAutoreleasePool alloc] init]; if (delegate && [delegate respondsToSelector:@selector(importerDidSave:)]) { [[NSNotificationCenter defaultCenter] addObserver:delegate selector:@selector(importerDidSave:) name:NSManagedObjectContextDidSaveNotification object:self.insertionContext]; } done = NO; self.dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateStyle:NSDateFormatterLongStyle]; [dateFormatter setTimeStyle:NSDateFormatterNoStyle]; // necessary because iTunes RSS feed is not localized, so if the device region has been set to other than US // the date formatter must be set to US locale in order to parse the dates [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; self.characterBuffer = [NSMutableData data]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:iTunesURL]; // create the connection with the request and start loading the data rssConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; // This creates a context for "push" parsing in which chunks of data that are not "well balanced" can be passed // to the context for streaming parsing. The handler structure defined above will be used for all the parsing. // The second argument, self, will be passed as user data to each of the SAX handlers. The last three arguments // are left blank to avoid creating a tree in memory. context = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL); if (rssConnection != nil) { do { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } while (!done); } // Display the total time spent finding a specific object for a relationship NSLog(@"lookup time %f", lookuptime); // Release resources used only in this thread. xmlFreeParserCtxt(context); self.characterBuffer = nil; self.dateFormatter = nil; self.rssConnection = nil; self.currentSong = nil; [theCache release]; theCache = nil; NSError *saveError = nil; NSAssert1([insertionContext save:&saveError], @"Unhandled error saving managed object context in import thread: %@", [saveError localizedDescription]); if (delegate && [delegate respondsToSelector:@selector(importerDidSave:)]) { [[NSNotificationCenter defaultCenter] removeObserver:delegate name:NSManagedObjectContextDidSaveNotification object:self.insertionContext]; } if (self.delegate != nil && [self.delegate respondsToSelector:@selector(importerDidFinishParsingData:)]) { [self.delegate importerDidFinishParsingData:self]; } [importPool release]; self.importPool = nil; } - (NSManagedObjectContext *)insertionContext { if (insertionContext == nil) { insertionContext = [[NSManagedObjectContext alloc] init]; [insertionContext setPersistentStoreCoordinator:self.persistentStoreCoordinator]; } return insertionContext; } - (void)forwardError:(NSError *)error { if (self.delegate != nil && [self.delegate respondsToSelector:@selector(importer:didFailWithError:)]) { [self.delegate importer:self didFailWithError:error]; } } - (NSEntityDescription *)songEntityDescription { if (songEntityDescription == nil) { songEntityDescription = [[NSEntityDescription entityForName:@"Song" inManagedObjectContext:self.insertionContext] retain]; } return songEntityDescription; } - (CategoryCache *)theCache { if (theCache == nil) { theCache = [[CategoryCache alloc] init]; theCache.managedObjectContext = self.insertionContext; } return theCache; } - (Song *)currentSong { if (currentSong == nil) { currentSong = [[Song alloc] initWithEntity:self.songEntityDescription insertIntoManagedObjectContext:self.insertionContext]; } return currentSong; } #pragma mark NSURLConnection Delegate methods // Forward errors to the delegate. - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [self performSelectorOnMainThread:@selector(forwardError:) withObject:error waitUntilDone:NO]; // Set the condition which ends the run loop. done = YES; } // Called when a chunk of data has been downloaded. - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // Process the downloaded chunk of data. xmlParseChunk(context, (const char *)[data bytes], [data length], 0); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // Signal the context that parsing is complete by passing "1" as the last parameter. xmlParseChunk(context, NULL, 0, 1); context = NULL; // Set the condition which ends the run loop. done = YES; } #pragma mark Parsing support methods static const NSUInteger kImportBatchSize = 20; - (void)finishedCurrentSong { parsingASong = NO; self.currentSong = nil; countForCurrentBatch++; // Periodically purge the autorelease pool and save the context. The frequency of this action may need to be tuned according to the // size of the objects being parsed. The goal is to keep the autorelease pool from growing too large, but // taking this action too frequently would be wasteful and reduce performance. if (countForCurrentBatch == kImportBatchSize) { [importPool release]; self.importPool = [[NSAutoreleasePool alloc] init]; NSError *saveError = nil; NSAssert1([insertionContext save:&saveError], @"Unhandled error saving managed object context in import thread: %@", [saveError localizedDescription]); countForCurrentBatch = 0; } } /* Character data is appended to a buffer until the current element ends. */ - (void)appendCharacters:(const char *)charactersFound length:(NSInteger)length { [characterBuffer appendBytes:charactersFound length:length]; } - (NSString *)currentString { // Create a string with the character data using UTF-8 encoding. UTF-8 is the default XML data encoding. NSString *currentString = [[[NSString alloc] initWithData:characterBuffer encoding:NSUTF8StringEncoding] autorelease]; [characterBuffer setLength:0]; return currentString; } @end #pragma mark SAX Parsing Callbacks // The following constants are the XML element names and their string lengths for parsing comparison. // The lengths include the null terminator, to ensure exact matches. static const char *kName_Item = "item"; static const NSUInteger kLength_Item = 5; static const char *kName_Title = "title"; static const NSUInteger kLength_Title = 6; static const char *kName_Category = "category"; static const NSUInteger kLength_Category = 9; static const char *kName_Itms = "itms"; static const NSUInteger kLength_Itms = 5; static const char *kName_Artist = "description"; static const NSUInteger kLength_Artist = 7; static const char *kName_Album = "description"; static const NSUInteger kLength_Album = 6; static const char *kName_ReleaseDate = "releasedate"; static const NSUInteger kLength_ReleaseDate = 12; /* This callback is invoked when the importer finds the beginning of a node in the XML. For this application, out parsing needs are relatively modest - we need only match the node name. An "item" node is a record of data about a song. In that case we create a new Song object. The other nodes of interest are several of the child nodes of the Song currently being parsed. For those nodes we want to accumulate the character data in a buffer. Some of the child nodes use a namespace prefix. */ static void startElementSAX(void *parsingContext, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes) { iTunesRSSImporter *importer = (iTunesRSSImporter *)parsingContext; // The second parameter to strncmp is the name of the element, which we known from the XML schema of the feed. // The third parameter to strncmp is the number of characters in the element name, plus 1 for the null terminator. if (prefix == NULL && !strncmp((const char *)localname, kName_Item, kLength_Item)) { importer.parsingASong = YES; } else if (importer.parsingASong && ( (prefix == NULL && (!strncmp((const char *)localname, kName_Title, kLength_Title) || !strncmp((const char *)localname, kName_Category, kLength_Category))) || ((prefix != NULL && !strncmp((const char *)prefix, kName_Itms, kLength_Itms)) && (!strncmp((const char *)localname, kName_Artist, kLength_Artist) || !strncmp((const char *)localname, kName_Album, kLength_Album) || !strncmp((const char *)localname, kName_ReleaseDate, kLength_ReleaseDate))) )) { importer.storingCharacters = YES; } } /* This callback is invoked when the parse reaches the end of a node. At that point we finish processing that node, if it is of interest to us. For "item" nodes, that means we have completed parsing a Song object. We pass the song to a method in the superclass which will eventually deliver it to the delegate. For the other nodes we care about, this means we have all the character data. The next step is to create an NSString using the buffer contents and store that with the current Song object. */ static void endElementSAX(void *parsingContext, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI) { iTunesRSSImporter *importer = (iTunesRSSImporter *)parsingContext; if (importer.parsingASong == NO) return; if (prefix == NULL) { if (!strncmp((const char *)localname, kName_Item, kLength_Item)) { [importer finishedCurrentSong]; } else if (!strncmp((const char *)localname, kName_Title, kLength_Title)) { importer.currentSong.title = importer.currentString; } else if (!strncmp((const char *)localname, kName_Category, kLength_Category)) { double before = [NSDate timeIntervalSinceReferenceDate]; Category *category = [importer.theCache categoryWithName:importer.currentString]; double delta = [NSDate timeIntervalSinceReferenceDate] - before; lookuptime += delta; importer.currentSong.category = category; } } else if (!strncmp((const char *)prefix, kName_Itms, kLength_Itms)) { if (!strncmp((const char *)localname, kName_Artist, kLength_Artist)) { NSString *string = importer.currentSong.artist; NSArray *strings = [string componentsSeparatedByString: @", "]; //importer.currentSong.artist = importer.currentString; } else if (!strncmp((const char *)localname, kName_Album, kLength_Album)) { importer.currentSong.album = importer.currentString; } else if (!strncmp((const char *)localname, kName_ReleaseDate, kLength_ReleaseDate)) { NSString *dateString = importer.currentString; importer.currentSong.releaseDate = [importer.dateFormatter dateFromString:dateString]; } } importer.storingCharacters = NO; } /* This callback is invoked when the parser encounters character data inside a node. The importer class determines how to use the character data. */ static void charactersFoundSAX(void *parsingContext, const xmlChar *characterArray, int numberOfCharacters) { iTunesRSSImporter *importer = (iTunesRSSImporter *)parsingContext; // A state variable, "storingCharacters", is set when nodes of interest begin and end. // This determines whether character data is handled or ignored. if (importer.storingCharacters == NO) return; [importer appendCharacters:(const char *)characterArray length:numberOfCharacters]; } /* A production application should include robust error handling as part of its parsing implementation. The specifics of how errors are handled depends on the application. */ static void errorEncounteredSAX(void *parsingContext, const char *errorMessage, ...) { // Handle errors as appropriate for your application. NSCAssert(NO, @"Unhandled error encountered during SAX parse."); } // The handler struct has positions for a large number of callback functions. If NULL is supplied at a given position, // that callback functionality won't be used. Refer to libxml documentation at http://www.xmlsoft.org for more information // about the SAX callbacks. static xmlSAXHandler simpleSAXHandlerStruct = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ NULL, /* hasExternalSubset */ NULL, /* resolveEntity */ NULL, /* getEntity */ NULL, /* entityDecl */ NULL, /* notationDecl */ NULL, /* attributeDecl */ NULL, /* elementDecl */ NULL, /* unparsedEntityDecl */ NULL, /* setDocumentLocator */ NULL, /* startDocument */ NULL, /* endDocument */ NULL, /* startElement*/ NULL, /* endElement */ NULL, /* reference */ charactersFoundSAX, /* characters */ NULL, /* ignorableWhitespace */ NULL, /* processingInstruction */ NULL, /* comment */ NULL, /* warning */ errorEncounteredSAX, /* error */ NULL, /* fatalError //: unused error() get all the errors */ NULL, /* getParameterEntity */ NULL, /* cdataBlock */ NULL, /* externalSubset */ XML_SAX2_MAGIC, // NULL, startElementSAX, /* startElementNs */ endElementSAX, /* endElementNs */ NULL, /* serror */ }; Thanks.

    Read the article

  • FMOD on non-playing audio

    - by coldrising
    Hey, is there any way to get the audio spectrum of a section of a song using FMOD if it is not playing? Can I render a full song waveform using FMOD (+opengl/openframeworks/etc.) before the song is playing?

    Read the article

  • XNA MediaPlayer fastforward/rewind

    - by bufferz
    Using XNA 4.0, I am currently playing songs from the user's PC/XBox360 using the following: Microsoft.Xna.Framework.Media.MediaPlayer.Play(Song song); I see that MediaPlayer has a static Property PlayPosition that, as I've researched, used to be a get/set property, but it has been updated to get-only. Are there any other methods/tricks I can use to explicitly set the playing position of a currently playing song?

    Read the article

  • Store data for songs MySQL DB

    - by Johan
    I'm storing a huge set of songs in a MySQL database. This is what I store in the 'songs' table: CREATE TABLE `songs` ( `song_id` int(10) unsigned NOT NULL auto_increment, `song_artist` varchar(255) NOT NULL, `song_track` varchar(255) NOT NULL, `song_mix` varchar(255) NOT NULL, `song_title` text NOT NULL, `song_hash` varchar(40) NOT NULL, `song_addtime` int(10) unsigned NOT NULL, `song_source` text NOT NULL, `song_file` varchar(255) NOT NULL, PRIMARY KEY (`song_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1857 DEFAULT CHARSET=latin1 Now I'd like to keep track of how many plays each song has, and other song-specific data that relates to the song. I don't want to keep adding fields to the 'songs' table for this. How can I store song related data a more efficient way? What's the best practice here?

    Read the article

  • php url routing question

    - by Ahmet vardar
    Hi, http://mysite.com/songs/company-name/song-name i want to redirect it to http://mysite.com/songs/index.php?name=company-name&song=song-name i read some articles about that mod_rewrite but actually i couldnt understand exactyly, i appreciate if you can help me. thanks

    Read the article

  • Using nodereference + views to create combined view

    - by Ian Silber
    I'm trying to set up a relational View but not sure how to do it. Here's an example of what I'm going for using the node types Artist and Song. Artist Song Length Bob Dylan Like a Rolling Stone 2:00 Bruce Springsteen Atlantic City 4:00 Burce Springsteen Born to Run 5:24 Van Morrison Domino 3:22 Van Morrison Brown Eyed Girl 4:30 Assuming I have an Artist node type that has a node reference to Song (set to unlimited) and a Song data type with an additional field for length, how would I go about configuring the view to output this view? Thanks! Ian

    Read the article

  • Broken Multithreading With Core Data

    - by spamguy
    This is a better-focused version of an earlier question that touches upon an entirely different subject from before. I am working on a Cocoa Core Data application with multiple threads. There is a Song and Artist; every Song has an Artist relation. There is a delegate code file not cited here; it more or less looks like the template XCode generates. I am far better working with the former technology than the latter, and any multithreading capability came from a Core Data template. When I'm doing all my ManagedObjectContext work in one method, I am fine. When I put fetch-or-insert-then-return-object work into a separate method, the application halts (but does not crash) at the new method's return statement, seen below. The new method even gets its own MOC to be safe, and it has not helped any. The result is one addition to Song and a halt after generating an Artist. I get no errors or exceptions, and I don't know why. I've debugged out the wazoo. My theory is that any errors occurring are in another thread, and the one I'm watching is waiting on something forever. What did I do wrong with getArtistObject: , and how can I fix it? Thanks. - (void)main { NSInteger songCount = 1; NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] init]; [moc setPersistentStoreCoordinator:[[self delegate] persistentStoreCoordinator]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextDidSave:) name:NSManagedObjectContextDidSaveNotification object:moc]; /* songDict generated here */ for (id key in songDict) { NSManagedObject *song = [NSEntityDescription insertNewObjectForEntityForName:@"Song" inManagedObjectContext:moc]; [song setValue:[songDictItem objectForKey:@"Name"] forKey:@"title"]; [song setValue:[self getArtistObject:(NSString *) [songDictItem objectForKey:@"Artist"]] forKey:@"artist"]; [songDictItem release]; songCount++; } NSError *error; if (![moc save:&error]) [NSApp presentError:error]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:moc]; [moc release], moc = nil; [[self delegate] importDone]; } - (NSManagedObject*) getArtistObject:(NSString*)theArtist { NSError *error = nil; NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] init]; [moc setPersistentStoreCoordinator:[[self delegate] persistentStoreCoordinator]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextDidSave:) name:NSManagedObjectContextDidSaveNotification object:moc]; NSFetchRequest *fetch = [[[NSFetchRequest alloc] init] autorelease]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Artist" inManagedObjectContext:moc]; [fetch setEntity:entityDescription]; // object to be returned NSManagedObject *artistObject = [[NSManagedObject alloc] initWithEntity:entityDescription insertIntoManagedObjectContext:moc]; // set predicate (artist name) NSPredicate *pred = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"name = \"%@\"", theArtist]]; [fetch setPredicate:pred]; NSArray *response = [moc executeFetchRequest:fetch error:&error]; if (error) [NSApp presentError:error]; if ([response count] == 0) // empty resultset --> no artists with this name { [artistObject setValue:theArtist forKey:@"name"]; NSLog(@"%@ not found. Adding.", theArtist); return artistObject; } else return [response objectAtIndex:0]; } @end

    Read the article

  • Android Multiple objects in SimpleAdapter

    - by Adam Sherratt
    I have a need (unless you can think of a better way) of passing multiple objects to a custom list adapter. I know that I'm barking up the wrong tree here, and would appreciate someone setting me on the right course! Thanks playlistadapter = new MyPlaylistAdapter(MyApplication.getAppContext(), songsList, retained_songsList, folderMode, R.layout.file_view, new String[] { "songTitle","songAlbum", "songPath" }, new int[] { R.id.checkTextView, R.id.text2, R.id.text3 }); And my adapter class: public class MyPlaylistAdapter extends SimpleAdapter{ private ArrayList <Song> songsList = new ArrayList<Song>(); private ArrayList <Song> retained_songsList = new ArrayList<Song>(); private ArrayList<Song> playlistcheck = new ArrayList<Song>(); private String folderMode; private String TAG = "AndroidMediaCenter"; public MyPlaylistAdapter(Context context,List<Song> SongsList, List<Song> Retained_songsList, String FolderMode,int resource, String[] from, int[] to) { super(context, null, resource, from, to); songsList.clear(); songsList.addAll(SongsList); Log.i(TAG, "MyPlayListAdapter Songslist = " + songsList.size()); retained_songsList.clear(); retained_songsList.addAll(Retained_songsList); folderMode = FolderMode; } public View getView(int position, View convertView, ViewGroup parent) { //PlayListViewHolder holder; CheckedTextView checkTextView; TextView text2; TextView text3; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) MyApplication.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); //LayoutInflater inflater=getLayoutInflater(); convertView=inflater.inflate(R.layout.file_view, parent, false); //convertView.setBackgroundColor(0xFF00FF00 ); //holder = new PlayListViewHolder(); checkTextView = (CheckedTextView) convertView.findViewById(R.id.checkTextView); text2 = (TextView) convertView.findViewById(R.id.text2); text3 = (TextView) convertView.findViewById(R.id.text3); //convertView.setTag(holder); } else { //holder = (PlayListViewHolder) convertView.getTag(); } //put something into textviews String tracks = null; String tracks_Details = null; String trackspath = null; tracks = songsList.get(position).getSongTitle(); tracks_Details = songsList.get(position).getAlbum() + " (" + songsList.get(position).getArtist() + ")"; trackspath = songsList.get(position).getSongPath(); checkTextView = (CheckedTextView) convertView.findViewById(R.id.checkTextView); text2 = (TextView) convertView.findViewById(R.id.text2); text3 = (TextView) convertView.findViewById(R.id.text3); checkTextView.setText(tracks); if(folderMode.equals("Playlists")){ checkTextView.setBackgroundColor(Color.GREEN); checkTextView.setChecked(false); try { int listsize_rs = retained_songsList.size(); for (int j = 0; j<listsize_rs;j++){ if((retained_songsList.get(j).getSongPath()).equals(songsList.get(position).getSongPath())){ checkTextView.setBackgroundColor(Color.TRANSPARENT); //Need to check here whether the checkedtextview is ticked or not checkTextView.setChecked(true); playlistcheck.add(songsList.get(position)); break; } } } catch (Exception e) { e.printStackTrace(); } }else { //Need to check here whether the checkedtextview is ticked or not try { if (songsList.get(position).getSongCheckedStatus()==true){ checkTextView.setChecked(true); }else{ checkTextView.setChecked(false); } } catch (Exception e) { e.printStackTrace(); } } text2.setText(tracks_Details); text3.setText(trackspath); Log.i(TAG, "MyPlayListAdapter Songslist = " + songsList.size()); return convertView; } } However, this doesn't inflate, throwing the following errors: 10-26 23:11:09.464: E/AndroidRuntime(2826): FATAL EXCEPTION: main 10-26 23:11:09.464: E/AndroidRuntime(2826): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.GetMusicComplete flg=0x10 } in com.Nmidia.AMC.MusicActivity$18@414c5770 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:765) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.os.Handler.handleCallback(Handler.java:615) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.os.Handler.dispatchMessage(Handler.java:92) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.os.Looper.loop(Looper.java:137) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.app.ActivityThread.main(ActivityThread.java:4745) 10-26 23:11:09.464: E/AndroidRuntime(2826): at java.lang.reflect.Method.invokeNative(Native Method) 10-26 23:11:09.464: E/AndroidRuntime(2826): at java.lang.reflect.Method.invoke(Method.java:511) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-26 23:11:09.464: E/AndroidRuntime(2826): at dalvik.system.NativeStart.main(Native Method) 10-26 23:11:09.464: E/AndroidRuntime(2826): Caused by: java.lang.NullPointerException 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.widget.SimpleAdapter.getCount(SimpleAdapter.java:93) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.widget.ListView.setAdapter(ListView.java:460) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.Nmidia.AMC.MusicActivity.setFilterMusic(MusicActivity.java:1230) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.Nmidia.AMC.MusicActivity$18.onReceive(MusicActivity.java:996) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:755) 10-26 23:11:09.464: E/AndroidRuntime(2826): ... 9 more

    Read the article

  • Sorting Objects in NSArray

    - by Sam Budda
    I have an NSArray with 3 objects in it. Each object is made up of 5 values. How can I sort by Date with in the objects? result: ( gg, "2012-10-28 01:34:00 +0000", "Church Bells", "pin_red", 1 )( iu, "2008-09-22 17:32:00 +0000", "Birthday Song", "pin_red", 1 )( "my birthday woo hoo", "2012-09-04 19:27:00 +0000", "Birthday Song", "pin_blue", 1 ) The results I am looking for - Sorted Array should look like this. ( iu, "2008-09-22 17:32:00 +0000", "Birthday Song", "pin_red", 1 ) ( "my birthday woo hoo", "2012-09-04 19:27:00 +0000", "Birthday Song", "pin_blue", 1 ) ( gg, "2012-10-28 01:34:00 +0000", "Church Bells", "pin_red", 1 ) I am getting this array from my nsdictionary object. dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:stringsPlistPath]; stringsMutableArray = [[NSMutableArray alloc] initWithObjects:nil]; for (id key in dictionary) { [stringsMutableArray addObject:[dictionary objectForKey:key]]; }

    Read the article

  • Multiple values one field mysql

    - by chloe
    Basically I have a a mysql database which i want to create containing the following tables: artist song album A song can belong to only one artist, however, a song could be in Multiple Albums. How would I go about implementing this in my mysql database. I've been stuck for a few days now :(

    Read the article

  • Flash music player stop working when I embed it into my index page

    - by janoChen
    Inside my /test folder/music_player/ have have a file called mini_player.swf. If I play it without embedding it anywhere, like this: http://ada.kiexpro.com/test/music_player/player_mini.swf everything is OK. But when I add it into my index page: http://ada.kiexpro.com/test/ the song doesn't start. I'm using a song_list.xml like this: <songs> <song> <track>She can dance too</track> <artist>Artist One</artist> <url>songs/song.mp3</url> </song> (continues)

    Read the article

  • Assign variable with variable in function

    - by freakazo
    Let's say we have def Foo(Bar=0,Song=0): print(Bar) print(Song) And I want to assign any one of the two parameters in the function with the variable sing and SongVal: Sing = Song SongVal = 2 So that it can be run like: Foo(Sing=SongVal) Where Sing would assign the Song parameter to the SongVal which is 2. The result should be printed like so: 0 2 So should I rewrite my function or is it possible to do it the way I want to? (With the code above you get an error saying Foo has no parameter Sing. Which I understand why, any way to overcome this without rewriting the function too much? Thanks in advance!

    Read the article

  • How can I create a boolean in the `if` statement within the for loop to check for existence of term prepended to filename %%f?

    - by user784637
    I have lyrics for about 60% of my song collection. The filename of the lyrics is the same as the file name of song with zzz_ prepended to the filename and .lrc as the extension. C:\Songs\album\song.mp3 C:\Songs\album\zzz_song.lrc I currently print the file names like so for /r "C:\Songs" %%f in (*.mp3 *.flac) do ( echo %%f ) How can I create a boolean in the if statement within the for loop as a check on the existence of lyrics files? I was thinking something like if exist zzz_%f echo zzz_%f.lrc but zzz_%f prepends zzz_ to the full file path (ex. zzz_C:\Songs\album\song.mp3) and .lrc is appended to the existing extension

    Read the article

  • How to get time difference in milliseconds

    - by jason45
    Hi, I can't wrap my brain around this one so I hope someone can help. I have a song track that has the song length in milliseconds. I also have the date the song played in DATETIME format. What I am trying to do is find out how many milliseconds is left in the song play time. Example $tracktime = 219238; $dateplayed = '2011-01-17 11:01:44'; $starttime = strtotime($dateplayed); I am using the following to determine time left but it does not seem correct. $curtime = time(); $timeleft = $starttime+round($tracktime/1000)-$curtime; Any help would be greatly appreciated.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >