3 Copyright 2008 Tor-Einar Jarnbjo
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
19 package org.omtk.vorbis {
21 import flash.utils.ByteArray;
22 import flash.utils.Endian;
23 import flash.utils.Dictionary;
24 import org.omtk.ogg.*;
26 public class CommentHeader {
28 private var _vendor:String;
29 private var _comments:Dictionary = new Dictionary();
31 public function CommentHeader(source:ByteArray)
36 private function init( source: ByteArray ): void
45 _vendor = readUtf8String(source);
47 var ucLength:int = source.readUnsignedInt();
49 for(var i:int = 0; i < ucLength; i++) {
50 var comment:String = readUtf8String(source);
51 var ix:int = comment.indexOf('=');
52 var key:String = comment.substring(0, ix);
53 var value:String = comment.substring(ix+1);
54 _comments[key.toUpperCase()]=value;
58 private function readUtf8String(source:ByteArray):String {
59 var length:uint = source.readUnsignedInt();
60 return source.readUTFBytes(length);
63 public function get vendor():String {
67 public function get comments():Dictionary {
71 public function get artist():String {
72 return _comments["ARTIST"];
75 public function get title():String {
76 return _comments["TITLE"];